Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePlenkov committed Nov 7, 2024
1 parent f729a22 commit d37f734
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 76 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
"dependencies": {
"fast-xml-parser": "^4.5.0"
}
}
}
4 changes: 1 addition & 3 deletions packages/components/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ module.exports = [
'@nx/dependency-checks': [
'error',
{
ignoredFiles: [
'{projectRoot}/*.config.{js,cjs,mjs,ts,cts,mts}',
],
ignoredFiles: ['{projectRoot}/*.config.{js,cjs,mjs,ts,cts,mts}'],
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"dependencies": {
"fast-xml-parser": "^4.5.0"
}
}
}
6 changes: 2 additions & 4 deletions packages/components/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
},
"test": {
"executor": "@nx/vite:test",
"outputs": [
"{options.reportsDirectory}"
],
"outputs": ["{options.reportsDirectory}"],
"options": {
"reportsDirectory": "{workspaceRoot}/coverage/{projectRoot}"
}
}
}
}
}
17 changes: 9 additions & 8 deletions packages/components/src/lib/abapgit/abapgit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ const package_abapgit = `<?xml version="1.0" encoding="utf-8"?>
</asx:values>
</asx:abap>
</abapGit>
`
`;

import { toAbapGitXML } from '../abapgit/abapgit'

describe("package", () => {
test("abapGit", () => {
expect(toAbapGitXML({ DEVC: { CTEXT: "test package" } }, 'LCL_OBJECT_DEVC')).to.eq(package_abapgit);
})
})
import { toAbapGitXML } from '../abapgit/abapgit';

describe('package', () => {
test('abapGit', () => {
expect(
toAbapGitXML({ DEVC: { CTEXT: 'test package' } }, 'LCL_OBJECT_DEVC')
).to.eq(package_abapgit);
});
});
52 changes: 24 additions & 28 deletions packages/components/src/lib/abapgit/abapgit.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@


import { XMLBuilder } from "fast-xml-parser";
import { XMLBuilder } from 'fast-xml-parser';

export function toAbapGitXML(data: unknown, serializer: string): string {

const builder = new XMLBuilder({ ignoreAttributes: false, format: true });

const payload = {
"?xml": {
"@_version": "1.0",
"@_encoding": "utf-8"
},
"abapGit": {
"asx:abap": {
"asx:values": data,
"@_xmlns:asx": "http://www.sap.com/abapxml",
"@_version": "1.0"
},
"@_version": "v1.0.0",
"@_serializer": serializer,
"@_serializer_version": "v1.0.0"
}
}

const xml = builder.build(payload);

return xml;

}
const builder = new XMLBuilder({ ignoreAttributes: false, format: true });

const payload = {
'?xml': {
'@_version': '1.0',
'@_encoding': 'utf-8',
},
abapGit: {
'asx:abap': {
'asx:values': data,
'@_xmlns:asx': 'http://www.sap.com/abapxml',
'@_version': '1.0',
},
'@_version': 'v1.0.0',
'@_serializer': serializer,
'@_serializer_version': 'v1.0.0',
},
};

const xml = builder.build(payload);

return xml;
}
22 changes: 11 additions & 11 deletions packages/components/src/lib/components/component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { toAbapGitXML } from "../abapgit/abapgit";
import { toAbapGitXML } from '../abapgit/abapgit';

export abstract class Component<T> {
input: T
constructor(input: T) {
this.input = input
}
abstract toAbapgit(): unknown
abstract get abapgitSerializer(): string;
toAbapgitXML(): string {
return toAbapGitXML(this.toAbapgit(), this.abapgitSerializer)
}
}
input: T;
constructor(input: T) {
this.input = input;
}
abstract toAbapgit(): unknown;
abstract get abapgitSerializer(): string;
toAbapgitXML(): string {
return toAbapGitXML(this.toAbapgit(), this.abapgitSerializer);
}
}
15 changes: 8 additions & 7 deletions packages/components/src/lib/components/devc/package.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ const package_abapgit = `<?xml version="1.0" encoding="utf-8"?>
</asx:values>
</asx:abap>
</abapGit>
`

describe("package", () => {
test("abapGit", () => {
expect(new Package({ description: "test package" }).toAbapgitXML()).eq(package_abapgit);
})
})
`;

describe('package', () => {
test('abapGit', () => {
expect(new Package({ description: 'test package' }).toAbapgitXML()).eq(
package_abapgit
);
});
});
26 changes: 13 additions & 13 deletions packages/components/src/lib/components/devc/package.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Component } from "../component"
import { Component } from '../component';

interface PackageInput {
description: string
description: string;
}

export class Package extends Component<PackageInput> {
override get abapgitSerializer(): string {
return "LCL_OBJECT_DEVC"
}
override toAbapgit(): unknown {
return {
DEVC: {
CTEXT: this.input.description
}
}
}
}
override get abapgitSerializer(): string {
return 'LCL_OBJECT_DEVC';
}
override toAbapgit(): unknown {
return {
DEVC: {
CTEXT: this.input.description,
},
};
}
}

0 comments on commit d37f734

Please sign in to comment.