Skip to content

Commit

Permalink
search help api checks improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed Feb 10, 2021
1 parent 8e9284a commit e1d5c90
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 132 deletions.
12 changes: 9 additions & 3 deletions abap-api-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,22 @@ Command line tool for pattern based applications with ABAP/HANA systems.
npm install -g abap-api-tools
```

With [SAP NWRFC SDK](https://support.sap.com/en/product/connectors/nwrfcsdk.html) binaries installed on your notebook, CLI tool can connect to ABAP systems. Check [where to download](https://launchpad.support.sap.com/#/notes/2573790) and [how to install](https://github.com/SAP/node-rfc/blob/master/doc/installation.md#sap-nwrfc-sdk-installation).
[SAP NWRFC SDK](https://support.sap.com/en/product/connectors/nwrfcsdk.html) binaries shall be installed on your notebook, for CLI connectivity to ABAP systems. Check [where to download](https://launchpad.support.sap.com/#/notes/2573790) and [how to install](https://github.com/SAP/node-rfc/blob/master/doc/installation.md#sap-nwrfc-sdk-installation).

Without [SAP NWRFC SDK](https://support.sap.com/en/product/connectors/nwrfcsdk.html), the `make` command and custom ui configurations can be tested with [ABAP annotations sample](https://github.com/SAP/fundamental-tools/tree/sample).

Using [docker container](https://github.com/SAP/fundamental-tools/tree/main/docker#abap-api-tools) with pre-installed SAP NWRFC SDK, no NodeJS or `abap-api-tools` installation are required. Just run:
Using CLI from [docker container](https://github.com/SAP/fundamental-tools/tree/main/docker#abap-api-tools), only docker is required on your notebook and CLI is invoked by:

```shell
docker exec cli abap
```

or with npm installation::

```shell
abap
```

## Usage

Create project folder and maintain ABAP system(s) destinations in `sapnwrfc.ini` file, for example:
Expand Down Expand Up @@ -80,7 +86,7 @@ MME:
dom_values: YWS_SHLP_DOMVALUES_GET
```
Run `abap` command to show help:
Run `abap` command, to show help:

```shell
abap
Expand Down
4 changes: 2 additions & 2 deletions abap-api-tools/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion abap-api-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "abap-api-tools",
"description": "ABAP api tools",
"version": "1.6.3",
"version": "1.6.4",
"homepage": "https://github.com/sap/fundamental-tools",
"author": "SAP",
"license": "Apache-2.0",
Expand Down
59 changes: 33 additions & 26 deletions abap-api-tools/src/ts/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,34 +157,41 @@ export class Backend {
`backend: ${this.api_name} dest: ${this.argv.dest} lang: ${argv.lang} : ${this.SPRAS} api: ${this.apilist}`
);

try {
const systemYamlPath = path.join(
DefaultFolder.userConfig,
"systems.yaml"
);
const systems = yamlLoad(systemYamlPath) as SystemsYamlType;
if (
this.argv.dest &&
systems[this.argv.dest] &&
systems[this.argv.dest].search_help_api
) {
this.search_help_api = systems[this.argv.dest].search_help_api;

for (const [apiKey, apiName] of Object.entries(this.search_help_api)) {
if (!["determine", "dom_values"].includes(apiKey)) {
throw new Error(
`Invalid key "${apiKey}" found in ${systemYamlPath}`
);
}
if (apiName.length > 30) {
throw new Error(
`Too long API name "${apiName}" found in ${systemYamlPath}`
);
// check if search help api configured
if (this.argv.dest && this.argv.cmd === Command.get) {
try {
const systemYamlPath = path.join(
DefaultFolder.userConfig,
"systems.yaml"
);
const systems = yamlLoad(systemYamlPath) as SystemsYamlType;
if (!systems) {
log.info(`systems.yaml not found: ${systemYamlPath}`);
} else if (!systems[this.argv.dest]) {
log.info(`system ${this.argv.dest} not found in systems.yaml`);
} else if (!systems[this.argv.dest].search_help_api) {
log.info(`search help api not configured for ${this.argv.dest}`);
} else {
this.search_help_api = systems[this.argv.dest].search_help_api;

for (const [apiKey, apiName] of Object.entries(
this.search_help_api
)) {
if (!["determine", "dom_values"].includes(apiKey)) {
throw new Error(
`Invalid key "${apiKey}" found in ${systemYamlPath}`
);
}
if (apiName.length > 30) {
throw new Error(
`Too long API name "${apiName}" found in ${systemYamlPath}`
);
}
}
}
} catch (ex) {
if (ex.code !== "ENOENT") throw ex; // ignore file not found error
}
} catch (ex) {
if (ex.code !== "ENOENT") throw ex; // ignore file not found error
}

// search helps processing
Expand Down Expand Up @@ -567,7 +574,7 @@ export class Backend {
log.info(
`\n${chalk.bold(this.api_name)} ${this.argv.dest} (${this.argv.lang}) ${
this.argv.textOnly ? "only texts" : ""
} ${this.getSearchHelps ? "sarch helps" : ""}\n`.replace(/ +/g, " ")
} ${this.getSearchHelps ? "search helps" : ""}\n`.replace(/ +/g, " ")
);

await this.client.open();
Expand Down
1 change: 0 additions & 1 deletion abap-api-tools/src/ts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export const Tagname = Object.freeze({
[ValueInput.list]: "combo",
});


// work folder
export const runningInDocker = process.env.container === "docker";
export const DockerVolume = "/work";
Expand Down
6 changes: 1 addition & 5 deletions abap-api-tools/src/ts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ export function getTimestamp(): string {
}

export function yamlLoad(fileName: string): unknown {
fs.readFileSync(fileName);
const y = yaml.load(
fs.readFileSync(fileName, { encoding: "utf-8", flag: "r" })
);
log.debug(`yaml load ${fileName}`);
return y;
return yaml.load(fs.readFileSync(fileName, { encoding: "utf-8", flag: "r" }));
}

export function yamlSave(fileName: string, obj: unknown, options = {}): void {
Expand Down
4 changes: 2 additions & 2 deletions doc/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ equipment:
- BAPI_EQUI_INSTALL # Install Equipment (Functional Location, Superior Equipment)
```
Cloud/web knowledge and skills are not required here, just standard ABAP development, like the ui will be implemented in ABAP.
Cloud/web knowledge and skills are not required here.
Nothing very new or exciting for ABAP developers, the business logic is exposed like the ui will be done in ABAP.
Just a regular ABAP development, like the ui will be implemented in ABAP.
## App Server
Expand Down
3 changes: 2 additions & 1 deletion docker/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# sap nwrfc sdk
nwrfcsdk*
nwrfcsdk*
sap
22 changes: 8 additions & 14 deletions docker/centos-systemd.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ ARG adminuser=www-admin
ARG dev_tools="sudo curl wget git unzip vim tree tmux iproute iputils"
ARG dev_libs="uuidd make zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel"

ARG nwrfc_pl=PL7
ARG nwrfc_source=/nwrfcsdk-portal/${nwrfc_pl}
ARG nwrfcsdk=nwrfcsdk-pl7
ARG nwrfc_source=/sap
ARG nwrfc_target=/usr/local/sap

# Add sudo user
Expand Down Expand Up @@ -71,24 +71,18 @@ USER ${adminuser}
# devtools-8 enable
RUN printf "\n# devtools-8\nsource /opt/rh/devtoolset-8/enable\n" >> ~/.bashrc

# git configuration
RUN \
git config --global http.sslVerify false && \
git config --global user.name bsrdjan && \
git config --global user.email srdjan.boskovic@sap.com

# sap nwrfc sdk
RUN printf "\n# nwrfc sdk \n" >> ~/.bashrc && \
printf "export SAPNWRFC_HOME=${nwrfc_target}/nwrfcsdk\n" >> ~/.bashrc
printf "export SAPNWRFC_HOME=${nwrfc_target}/${nwrfcsdk}\n" >> ~/.bashrc
USER root
RUN mkdir -p ${nwrfc_target}
COPY ${nwrfc_source}/linux/nwrfcsdk ${nwrfc_target}/nwrfcsdk
RUN chmod -R a+r ${nwrfc_target}/nwrfcsdk && \
chmod -R a+x ${nwrfc_target}/nwrfcsdk/bin && \
printf "# include nwrfcsdk\n${nwrfc_target}/nwrfcsdk/lib\n" | tee /etc/ld.so.conf.d/nwrfcsdk.conf && \
COPY ${nwrfc_source} ${nwrfc_target}
RUN chmod -R a+r ${nwrfc_target}/${nwrfcsdk} && \
chmod -R a+x ${nwrfc_target}/${nwrfcsdk}/bin && \
chmod -R a+x ${nwrfc_target}/${nwrfcsdk}/lib && \
printf "# include nwrfcsdk\n${nwrfc_target}/${nwrfcsdk}/lib\n" | tee /etc/ld.so.conf.d/nwrfcsdk.conf && \
ldconfig && ldconfig -p | grep sap

USER root
RUN rm -rf /tmp/* && \
systemctl mask systemd-machine-id-commit && systemctl enable multi-user.target && systemctl set-default multi-user.target
VOLUME [ "/sys/fs/cgroup" ]
Expand Down
1 change: 1 addition & 0 deletions docker/python-39-nwrfcsdk.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ARG adminuser=www-admin
ARG nwrfcsdk=nwrfcsdk-pl7
ARG nwrfc_source=/sap
ARG nwrfc_target=/usr/local/sap

ARG dev_python="pip wheel pytest cython ipython"
ARG dev_tools="sudo curl wget git unzip vim tree tmux iproute2 iputils-ping"
ARG dev_libs="build-essential make libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev"
Expand Down
77 changes: 0 additions & 77 deletions docker/python-39.Dockerfile

This file was deleted.

Loading

0 comments on commit e1d5c90

Please sign in to comment.