Skip to content

Commit

Permalink
closes #8, closes #9; Fix exceptions raised for non-mandatory configu…
Browse files Browse the repository at this point in the history
…rations
  • Loading branch information
bsrdjan committed Feb 2, 2021
1 parent cda0979 commit bd8a19d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
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.2.1",
"version": "1.2.2",
"homepage": "https://github.com/sap/fundamental-tools",
"author": "SAP",
"license": "Apache-2.0",
Expand Down
25 changes: 17 additions & 8 deletions abap-api-tools/src/ts/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,27 @@ export class Backend {
this.client = new Client(connectionParameters);

try {
const systemYmlPath = path.join(DefaultFolder.userConfig, "systems.yaml");
const systems = yamlLoad(systemYmlPath) as SystemsYamlType;
if (this.argv.dest && systems[this.argv.dest]) {
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 k of Object.keys(this.search_help_api)) {
if (!["determine", "dom_values"].includes(k)) {
throw new Error(`Invalid key "${k}" found in ${systemYmlPath}`);
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 (this.search_help_api[k].length > 30) {
if (apiName.length > 30) {
throw new Error(
`Too long API name: ${this.search_help_api[k]}, found in ${systemYmlPath}[${this.argv.dest}][${k}]`
`Too long API name "${apiName}" found in ${systemYamlPath}`
);
}
}
Expand Down
10 changes: 6 additions & 4 deletions abap-api-tools/src/ts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ export const DefaultFolder = Object.freeze({
});

const localFrameworks: string[] = [];
for (const fileName of fs.readdirSync(DefaultFolder.userConfig)) {
const m = fileName.match(/-abap.yaml$/);
if (m !== null) {
localFrameworks.push(fileName.substring(0, m.index));
if (fs.existsSync(DefaultFolder.userConfig)) {
for (const fileName of fs.readdirSync(DefaultFolder.userConfig)) {
const m = fileName.match(/-abap.yaml$/);
if (m !== null) {
localFrameworks.push(fileName.substring(0, m.index));
}
}
}
export const UIFrameworksLocal = Object.freeze(localFrameworks);
Expand Down

0 comments on commit bd8a19d

Please sign in to comment.