@tahminator/pipeline 1.0.55 → 1.0.56
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/upload-npm/beta/index.js +4 -1
- package/dist/utils/client.d.ts +0 -1
- package/dist/utils/client.js +0 -13
- package/dist/versioning/base.d.ts +6 -0
- package/dist/versioning/base.js +16 -0
- package/dist/versioning/client.d.ts +7 -0
- package/dist/versioning/client.js +20 -0
- package/dist/versioning/index.d.ts +2 -0
- package/dist/versioning/index.js +2 -0
- package/dist/versioning/java/maven/index.d.ts +6 -0
- package/dist/versioning/java/maven/index.js +28 -0
- package/dist/versioning/jsts/index.d.ts +5 -0
- package/dist/versioning/jsts/index.js +13 -0
- package/dist/versioning/types.d.ts +11 -0
- package/dist/versioning/types.js +5 -0
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import { EnvClient, EnvClientStrategy } from "../../../env";
|
|
|
4
4
|
import { GitHubClient } from "../../../gh";
|
|
5
5
|
import { NPMClient } from "../../../npm";
|
|
6
6
|
import { Utils } from "../../../utils";
|
|
7
|
+
import { VersioningClient } from "../../../versioning";
|
|
8
|
+
import { VersioningStrategy } from "../../../versioning/types";
|
|
7
9
|
const { sha, prId } = await yargs(hideBin(process.argv))
|
|
8
10
|
.option("sha", {
|
|
9
11
|
type: "string",
|
|
@@ -24,13 +26,14 @@ async function main() {
|
|
|
24
26
|
privateKey: await Utils.decodeBase64EncodedString(githubAppPrivateKeyB64),
|
|
25
27
|
});
|
|
26
28
|
const npmClient = await NPMClient.create();
|
|
29
|
+
const versioningClient = new VersioningClient(VersioningStrategy.JSTS);
|
|
27
30
|
const shortSha = await getShortSha(sha);
|
|
28
31
|
const lastTag = (await ghClient.getLatestTag()) ?? GitHubClient.BASE_VERSION;
|
|
29
32
|
const betaVersion = `${lastTag}-beta.${shortSha}`;
|
|
30
33
|
if (!Utils.SemVer.validate(betaVersion)) {
|
|
31
34
|
throw new Error(`Generated invalid beta version: ${betaVersion}`);
|
|
32
35
|
}
|
|
33
|
-
await
|
|
36
|
+
await versioningClient.update(betaVersion);
|
|
34
37
|
await npmClient.publish(false, true);
|
|
35
38
|
console.log(`Uploaded ${betaVersion} to NPM.`);
|
|
36
39
|
await ghClient.sendPrMessage({
|
package/dist/utils/client.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export declare class Utils {
|
|
|
9
9
|
static Log: typeof Log;
|
|
10
10
|
static SemVer: typeof SemVer;
|
|
11
11
|
static generateShortId(...args: Parameters<typeof generateShortId>): string;
|
|
12
|
-
static updateAllPackageJsonsWithVersion(version: string): Promise<void>;
|
|
13
12
|
static isCmdAvailable(...args: Parameters<typeof isCmdAvailable>): Promise<boolean>;
|
|
14
13
|
static decodeBase64EncodedString(...args: Parameters<typeof decodeBase64EncodedString>): Promise<string>;
|
|
15
14
|
}
|
package/dist/utils/client.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { $ } from "bun";
|
|
2
1
|
import { decodeBase64EncodedString } from "./b64";
|
|
3
2
|
import { isCmdAvailable } from "./cmd";
|
|
4
3
|
import { Colors } from "./colors";
|
|
@@ -13,18 +12,6 @@ export class Utils {
|
|
|
13
12
|
static generateShortId(...args) {
|
|
14
13
|
return generateShortId(...args);
|
|
15
14
|
}
|
|
16
|
-
static async updateAllPackageJsonsWithVersion(version) {
|
|
17
|
-
const files = (await $ `find . -name "package.json" -not -path "*/node_modules/*"`.text())
|
|
18
|
-
.trim()
|
|
19
|
-
.split("\n");
|
|
20
|
-
for (const fileLocation of files) {
|
|
21
|
-
const file = Bun.file(fileLocation);
|
|
22
|
-
const pkg = await file.json();
|
|
23
|
-
pkg.version = version;
|
|
24
|
-
await Bun.write(fileLocation, JSON.stringify(pkg, null, 2) + "\n");
|
|
25
|
-
console.log(`Successfully updated version in ${fileLocation} to ${version}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
15
|
static async isCmdAvailable(...args) {
|
|
29
16
|
return isCmdAvailable(...args);
|
|
30
17
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IVersioningClient } from "./types";
|
|
2
|
+
export declare abstract class BaseVersioningClient implements IVersioningClient {
|
|
3
|
+
abstract update(version: string): Promise<void>;
|
|
4
|
+
protected logFileLocationUpdated(fileLocation: string, version: string): void;
|
|
5
|
+
protected findFiles(filePattern: string, pathExclusionRegex?: RegExp): Promise<string[]>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class BaseVersioningClient {
|
|
2
|
+
logFileLocationUpdated(fileLocation, version) {
|
|
3
|
+
console.log(`Successfully updated version in ${fileLocation} to ${version}`);
|
|
4
|
+
}
|
|
5
|
+
async findFiles(filePattern, pathExclusionRegex) {
|
|
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;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { VersioningStrategy, type IVersioningClient } from "./types";
|
|
2
|
+
export declare class VersioningClient implements IVersioningClient {
|
|
3
|
+
private readonly delegate;
|
|
4
|
+
constructor(strategy: VersioningStrategy);
|
|
5
|
+
private getDelegate;
|
|
6
|
+
update(version: string): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JavaMavenVersioningClient } from "./java/maven";
|
|
2
|
+
import { JavascriptPackageJsonVersioningClient } from "./jsts";
|
|
3
|
+
import { VersioningStrategy } from "./types";
|
|
4
|
+
export class VersioningClient {
|
|
5
|
+
delegate;
|
|
6
|
+
constructor(strategy) {
|
|
7
|
+
this.delegate = this.getDelegate(strategy);
|
|
8
|
+
}
|
|
9
|
+
getDelegate(strategy) {
|
|
10
|
+
switch (strategy) {
|
|
11
|
+
case VersioningStrategy.JSTS:
|
|
12
|
+
return new JavascriptPackageJsonVersioningClient();
|
|
13
|
+
case VersioningStrategy.JAVA_MAVEN:
|
|
14
|
+
return new JavaMavenVersioningClient();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async update(version) {
|
|
18
|
+
await this.delegate.update(version);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IJavaMavenVersioningClient } from "../../types";
|
|
2
|
+
import { BaseVersioningClient } from "../../base";
|
|
3
|
+
export declare class JavaMavenVersioningClient extends BaseVersioningClient implements IJavaMavenVersioningClient {
|
|
4
|
+
private getVersionNode;
|
|
5
|
+
update(version: string): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { XmlElement, XmlParser, XmlText } from "xml-trueformat";
|
|
2
|
+
import { BaseVersioningClient } from "../../base";
|
|
3
|
+
export class JavaMavenVersioningClient extends BaseVersioningClient {
|
|
4
|
+
getVersionNode(projectNode) {
|
|
5
|
+
const versionNode = projectNode.children.find((child) => child instanceof XmlElement && child.tagName === "version");
|
|
6
|
+
if (!versionNode) {
|
|
7
|
+
throw new Error("Can't find version tag inside of project tag in pom.xml");
|
|
8
|
+
}
|
|
9
|
+
return versionNode;
|
|
10
|
+
}
|
|
11
|
+
async update(version) {
|
|
12
|
+
const files = await this.findFiles("pom.xml");
|
|
13
|
+
for (const fileLocation of files) {
|
|
14
|
+
const file = Bun.file(fileLocation);
|
|
15
|
+
const oldPomStr = await file.text();
|
|
16
|
+
const pom = XmlParser.parse(oldPomStr);
|
|
17
|
+
const projectNode = pom.getRootElement();
|
|
18
|
+
if (projectNode.tagName !== "project") {
|
|
19
|
+
throw new Error("Can't find project tag inside of pom.xml");
|
|
20
|
+
}
|
|
21
|
+
const versionNode = this.getVersionNode(projectNode);
|
|
22
|
+
versionNode.children = [new XmlText(version)];
|
|
23
|
+
const newPomStr = pom.toString();
|
|
24
|
+
await Bun.write(fileLocation, newPomStr);
|
|
25
|
+
this.logFileLocationUpdated(fileLocation, version);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IJavascriptPackageJsonVersioningClient } from "../types";
|
|
2
|
+
import { BaseVersioningClient } from "../base";
|
|
3
|
+
export declare class JavascriptPackageJsonVersioningClient extends BaseVersioningClient implements IJavascriptPackageJsonVersioningClient {
|
|
4
|
+
update(version: string): Promise<void>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseVersioningClient } from "../base";
|
|
2
|
+
export class JavascriptPackageJsonVersioningClient extends BaseVersioningClient {
|
|
3
|
+
async update(version) {
|
|
4
|
+
const files = await this.findFiles("**/package.json", /(^|\/)node_modules\//);
|
|
5
|
+
for (const fileLocation of files) {
|
|
6
|
+
const file = Bun.file(fileLocation);
|
|
7
|
+
const pkg = await file.json();
|
|
8
|
+
pkg.version = version;
|
|
9
|
+
await Bun.write(fileLocation, JSON.stringify(pkg, null, 2) + "\n");
|
|
10
|
+
this.logFileLocationUpdated(fileLocation, version);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum VersioningStrategy {
|
|
2
|
+
JSTS = 0,
|
|
3
|
+
JAVA_MAVEN = 1
|
|
4
|
+
}
|
|
5
|
+
export interface IVersioningClient {
|
|
6
|
+
update(version: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface IJavascriptPackageJsonVersioningClient extends IVersioningClient {
|
|
9
|
+
}
|
|
10
|
+
export interface IJavaMavenVersioningClient extends IVersioningClient {
|
|
11
|
+
}
|
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.
|
|
6
|
+
"version": "1.0.56",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|
|
@@ -52,8 +52,11 @@
|
|
|
52
52
|
"@octokit/rest": "^22.0.1",
|
|
53
53
|
"@pulumi/pulumi": "^3.230.0",
|
|
54
54
|
"ansi-to-html": "^0.7.2",
|
|
55
|
+
"fast-xml-builder": "^1.1.5",
|
|
56
|
+
"fast-xml-parser": "^5.7.2",
|
|
55
57
|
"neverthrow": "^8.2.0",
|
|
56
58
|
"semver": "^7.7.4",
|
|
59
|
+
"xml-trueformat": "^0.9.5",
|
|
57
60
|
"yaml": "^2.8.2",
|
|
58
61
|
"yargs": "^18.0.0",
|
|
59
62
|
"zod": "^4.3.6"
|