@tahminator/pipeline 1.0.55-beta.987212cf → 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.
|
@@ -2,5 +2,5 @@ import type { IVersioningClient } from "./types";
|
|
|
2
2
|
export declare abstract class BaseVersioningClient implements IVersioningClient {
|
|
3
3
|
abstract update(version: string): Promise<void>;
|
|
4
4
|
protected logFileLocationUpdated(fileLocation: string, version: string): void;
|
|
5
|
-
protected findFiles(filePattern: string, pathExclusionRegex?:
|
|
5
|
+
protected findFiles(filePattern: string, pathExclusionRegex?: RegExp): Promise<string[]>;
|
|
6
6
|
}
|
package/dist/versioning/base.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { $ } from "bun";
|
|
2
1
|
export class BaseVersioningClient {
|
|
3
2
|
logFileLocationUpdated(fileLocation, version) {
|
|
4
3
|
console.log(`Successfully updated version in ${fileLocation} to ${version}`);
|
|
5
4
|
}
|
|
6
5
|
async findFiles(filePattern, pathExclusionRegex) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const glob = new Bun.Glob(filePattern);
|
|
7
|
+
const files = [];
|
|
8
|
+
for await (const file of glob.scan(".")) {
|
|
9
|
+
if (pathExclusionRegex && pathExclusionRegex.test(file)) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
files.push(file);
|
|
13
|
+
}
|
|
14
|
+
return files;
|
|
10
15
|
}
|
|
11
16
|
}
|
|
@@ -4,5 +4,8 @@ export declare class JavaMavenVersioningClient extends BaseVersioningClient impl
|
|
|
4
4
|
private readonly parser;
|
|
5
5
|
private readonly builder;
|
|
6
6
|
constructor();
|
|
7
|
+
private getProjectNode;
|
|
8
|
+
private isVersionElement;
|
|
9
|
+
private getVersionNode;
|
|
7
10
|
update(version: string): Promise<void>;
|
|
8
11
|
}
|
|
@@ -18,19 +18,32 @@ export class JavaMavenVersioningClient extends BaseVersioningClient {
|
|
|
18
18
|
attributeNamePrefix: "@_",
|
|
19
19
|
});
|
|
20
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
|
+
}
|
|
31
|
+
getVersionNode(projectNode) {
|
|
32
|
+
const versionNode = projectNode.project.find((node) => this.isVersionElement(node));
|
|
33
|
+
if (!versionNode) {
|
|
34
|
+
throw new Error("Can't find version tag inside of project tag in pom.xml");
|
|
35
|
+
}
|
|
36
|
+
return versionNode;
|
|
37
|
+
}
|
|
21
38
|
async update(version) {
|
|
22
|
-
const files = await this.findFiles("
|
|
39
|
+
const files = await this.findFiles("pom.xml");
|
|
23
40
|
for (const fileLocation of files) {
|
|
24
41
|
const file = Bun.file(fileLocation);
|
|
25
42
|
const oldPomStr = await file.text();
|
|
26
43
|
const pom = this.parser.parse(oldPomStr);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
if (!pom.project.version) {
|
|
31
|
-
throw new Error("Can't find version tag inside of project tag in pom.xml");
|
|
32
|
-
}
|
|
33
|
-
pom.project.version = version;
|
|
44
|
+
const projectNode = this.getProjectNode(pom);
|
|
45
|
+
const versionNode = this.getVersionNode(projectNode);
|
|
46
|
+
versionNode.version = [{ "#text": version }];
|
|
34
47
|
const newPomStr = this.builder.build(pom);
|
|
35
48
|
await Bun.write(fileLocation, newPomStr);
|
|
36
49
|
this.logFileLocationUpdated(fileLocation, version);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseVersioningClient } from "../base";
|
|
2
2
|
export class JavascriptPackageJsonVersioningClient extends BaseVersioningClient {
|
|
3
3
|
async update(version) {
|
|
4
|
-
const files = await this.findFiles("package.json",
|
|
4
|
+
const files = await this.findFiles("**/package.json", /(^|\/)node_modules\//);
|
|
5
5
|
for (const fileLocation of files) {
|
|
6
6
|
const file = Bun.file(fileLocation);
|
|
7
7
|
const pkg = await file.json();
|
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
|
},
|