@tahminator/pipeline 1.0.55-beta.f8030759 → 1.0.55-beta.fc0de91b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { IJavaMavenVersioningClient } from "../../types";
|
|
2
2
|
import { BaseVersioningClient } from "../../base";
|
|
3
3
|
export declare class JavaMavenVersioningClient extends BaseVersioningClient implements IJavaMavenVersioningClient {
|
|
4
|
+
private readonly parser;
|
|
5
|
+
private readonly builder;
|
|
6
|
+
constructor();
|
|
7
|
+
private getProjectNode;
|
|
8
|
+
private isVersionElement;
|
|
4
9
|
private getVersionNode;
|
|
5
10
|
update(version: string): Promise<void>;
|
|
6
11
|
}
|
|
@@ -1,8 +1,35 @@
|
|
|
1
|
-
import
|
|
1
|
+
import XMLBuilderClient, {} from "fast-xml-builder";
|
|
2
|
+
import { XMLParser } from "fast-xml-parser";
|
|
2
3
|
import { BaseVersioningClient } from "../../base";
|
|
3
4
|
export class JavaMavenVersioningClient extends BaseVersioningClient {
|
|
5
|
+
parser;
|
|
6
|
+
builder;
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.parser = new XMLParser({
|
|
10
|
+
ignoreAttributes: false,
|
|
11
|
+
preserveOrder: true,
|
|
12
|
+
attributeNamePrefix: "@_",
|
|
13
|
+
allowBooleanAttributes: true,
|
|
14
|
+
});
|
|
15
|
+
this.builder = new XMLBuilderClient({
|
|
16
|
+
ignoreAttributes: false,
|
|
17
|
+
preserveOrder: true,
|
|
18
|
+
attributeNamePrefix: "@_",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
getProjectNode(pom) {
|
|
22
|
+
const projectNode = pom.find((node) => "project" in node);
|
|
23
|
+
if (!projectNode) {
|
|
24
|
+
throw new Error("Can't find project tag inside of pom.xml");
|
|
25
|
+
}
|
|
26
|
+
return projectNode;
|
|
27
|
+
}
|
|
28
|
+
isVersionElement(node) {
|
|
29
|
+
return "version" in node;
|
|
30
|
+
}
|
|
4
31
|
getVersionNode(projectNode) {
|
|
5
|
-
const versionNode = projectNode.
|
|
32
|
+
const versionNode = projectNode.project.find((node) => this.isVersionElement(node));
|
|
6
33
|
if (!versionNode) {
|
|
7
34
|
throw new Error("Can't find version tag inside of project tag in pom.xml");
|
|
8
35
|
}
|
|
@@ -13,14 +40,11 @@ export class JavaMavenVersioningClient extends BaseVersioningClient {
|
|
|
13
40
|
for (const fileLocation of files) {
|
|
14
41
|
const file = Bun.file(fileLocation);
|
|
15
42
|
const oldPomStr = await file.text();
|
|
16
|
-
const pom =
|
|
17
|
-
const projectNode =
|
|
18
|
-
if (projectNode.tagName !== "project") {
|
|
19
|
-
throw new Error("Can't find project tag inside of pom.xml");
|
|
20
|
-
}
|
|
43
|
+
const pom = this.parser.parse(oldPomStr);
|
|
44
|
+
const projectNode = this.getProjectNode(pom);
|
|
21
45
|
const versionNode = this.getVersionNode(projectNode);
|
|
22
|
-
versionNode.
|
|
23
|
-
const newPomStr =
|
|
46
|
+
versionNode.version = [{ "#text": version }];
|
|
47
|
+
const newPomStr = this.builder.build(pom);
|
|
24
48
|
await Bun.write(fileLocation, newPomStr);
|
|
25
49
|
this.logFileLocationUpdated(fileLocation, version);
|
|
26
50
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Tahmid Ahmed",
|
|
5
5
|
"description": "A collection of Bun shell scripts that can be re-used in various CICD pipelines.",
|
|
6
|
-
"version": "1.0.55-beta.
|
|
6
|
+
"version": "1.0.55-beta.fc0de91b",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
"fast-xml-parser": "^5.7.2",
|
|
57
57
|
"neverthrow": "^8.2.0",
|
|
58
58
|
"semver": "^7.7.4",
|
|
59
|
-
"xml-trueformat": "^0.9.5",
|
|
60
59
|
"yaml": "^2.8.2",
|
|
61
60
|
"yargs": "^18.0.0",
|
|
62
61
|
"zod": "^4.3.6"
|