@tahminator/pipeline 1.0.56-beta.a972db37 → 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/internal/upload-npm/beta/index.js +2 -2
- package/dist/versioning/{updating/base.d.ts → base.d.ts} +2 -2
- package/dist/versioning/{updating/base.js → base.js} +1 -1
- package/dist/versioning/client.d.ts +2 -21
- package/dist/versioning/client.js +6 -56
- package/dist/versioning/java/maven/index.d.ts +6 -0
- package/dist/versioning/{updating/java → java}/maven/index.js +2 -2
- package/dist/versioning/jsts/index.d.ts +5 -0
- package/dist/versioning/{updating/jsts → jsts}/index.js +2 -2
- package/dist/versioning/types.d.ts +4 -21
- package/dist/versioning/types.js +5 -5
- package/package.json +1 -1
- package/dist/versioning/updating/java/maven/index.d.ts +0 -6
- package/dist/versioning/updating/jsts/index.d.ts +0 -5
|
@@ -5,7 +5,7 @@ import { GitHubClient } from "../../../gh";
|
|
|
5
5
|
import { NPMClient } from "../../../npm";
|
|
6
6
|
import { Utils } from "../../../utils";
|
|
7
7
|
import { VersioningClient } from "../../../versioning";
|
|
8
|
-
import {
|
|
8
|
+
import { VersioningStrategy } from "../../../versioning/types";
|
|
9
9
|
const { sha, prId } = await yargs(hideBin(process.argv))
|
|
10
10
|
.option("sha", {
|
|
11
11
|
type: "string",
|
|
@@ -26,7 +26,7 @@ async function main() {
|
|
|
26
26
|
privateKey: await Utils.decodeBase64EncodedString(githubAppPrivateKeyB64),
|
|
27
27
|
});
|
|
28
28
|
const npmClient = await NPMClient.create();
|
|
29
|
-
const versioningClient = new VersioningClient(
|
|
29
|
+
const versioningClient = new VersioningClient(VersioningStrategy.JSTS);
|
|
30
30
|
const shortSha = await getShortSha(sha);
|
|
31
31
|
const lastTag = (await ghClient.getLatestTag()) ?? GitHubClient.BASE_VERSION;
|
|
32
32
|
const betaVersion = `${lastTag}-beta.${shortSha}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare abstract class
|
|
1
|
+
import type { IVersioningClient } from "./types";
|
|
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
5
|
protected findFiles(filePattern: string, pathExclusionRegex?: RegExp): Promise<string[]>;
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { VersionUpdatingStrategy, type IVersioningClient } from "./types";
|
|
1
|
+
import { VersioningStrategy, type IVersioningClient } from "./types";
|
|
3
2
|
export declare class VersioningClient implements IVersioningClient {
|
|
4
|
-
private readonly githubClient;
|
|
5
|
-
private static readonly INITIAL_VERSION;
|
|
6
3
|
private readonly delegate;
|
|
7
|
-
constructor(
|
|
4
|
+
constructor(strategy: VersioningStrategy);
|
|
8
5
|
private getDelegate;
|
|
9
|
-
private parseOrThrow;
|
|
10
6
|
update(version: string): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* generate next version tag.
|
|
13
|
-
*
|
|
14
|
-
* If `baseVersion` is not passed in:
|
|
15
|
-
* - if the repository has no tags yet, it will return `1.0.0`
|
|
16
|
-
* - otherwise, it will bump the latest tag's patch number
|
|
17
|
-
*
|
|
18
|
-
* if `baseVersion` is passed in, it will consult the github client and do the following:
|
|
19
|
-
*
|
|
20
|
-
* - if the github client reports a latest tag with the same `MAJOR` and `MINOR` version as `baseVersion`, it will just bump `PATCH` number
|
|
21
|
-
* - if the github client reports a latest tag with a lower `MAJOR` and `MINOR` version than `baseVersion`, it will match `baseVersion`'s `MAJOR` & `MINOR`. __It will NOT bump `PATCH` number.__
|
|
22
|
-
*
|
|
23
|
-
* `baseVersion` must set patch number to `0`. (e.g. `1.0.0`, `1.5.0`, `2.0.0`, etc.)
|
|
24
|
-
*/
|
|
25
|
-
next(baseVersion?: string, ...opts: Parameters<GitHubClient["getLatestTag"]>): Promise<string>;
|
|
26
7
|
}
|
|
@@ -1,70 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { JavascriptPackageJsonVersioningClient } from "./updating/jsts";
|
|
1
|
+
import { JavaMavenVersioningClient } from "./java/maven";
|
|
2
|
+
import { JavascriptPackageJsonVersioningClient } from "./jsts";
|
|
3
|
+
import { VersioningStrategy } from "./types";
|
|
5
4
|
export class VersioningClient {
|
|
6
|
-
githubClient;
|
|
7
|
-
static INITIAL_VERSION = "1.0.0";
|
|
8
5
|
delegate;
|
|
9
|
-
constructor(
|
|
10
|
-
this.githubClient = githubClient;
|
|
6
|
+
constructor(strategy) {
|
|
11
7
|
this.delegate = this.getDelegate(strategy);
|
|
12
8
|
}
|
|
13
9
|
getDelegate(strategy) {
|
|
14
10
|
switch (strategy) {
|
|
15
|
-
case
|
|
11
|
+
case VersioningStrategy.JSTS:
|
|
16
12
|
return new JavascriptPackageJsonVersioningClient();
|
|
17
|
-
case
|
|
13
|
+
case VersioningStrategy.JAVA_MAVEN:
|
|
18
14
|
return new JavaMavenVersioningClient();
|
|
19
15
|
}
|
|
20
16
|
}
|
|
21
|
-
parseOrThrow(label, v) {
|
|
22
|
-
const s = semver.parse(v);
|
|
23
|
-
if (!s) {
|
|
24
|
-
throw new Error(`${label} is not valid semver`);
|
|
25
|
-
}
|
|
26
|
-
return s;
|
|
27
|
-
}
|
|
28
17
|
async update(version) {
|
|
29
18
|
await this.delegate.update(version);
|
|
30
19
|
}
|
|
31
|
-
/**
|
|
32
|
-
* generate next version tag.
|
|
33
|
-
*
|
|
34
|
-
* If `baseVersion` is not passed in:
|
|
35
|
-
* - if the repository has no tags yet, it will return `1.0.0`
|
|
36
|
-
* - otherwise, it will bump the latest tag's patch number
|
|
37
|
-
*
|
|
38
|
-
* if `baseVersion` is passed in, it will consult the github client and do the following:
|
|
39
|
-
*
|
|
40
|
-
* - if the github client reports a latest tag with the same `MAJOR` and `MINOR` version as `baseVersion`, it will just bump `PATCH` number
|
|
41
|
-
* - if the github client reports a latest tag with a lower `MAJOR` and `MINOR` version than `baseVersion`, it will match `baseVersion`'s `MAJOR` & `MINOR`. __It will NOT bump `PATCH` number.__
|
|
42
|
-
*
|
|
43
|
-
* `baseVersion` must set patch number to `0`. (e.g. `1.0.0`, `1.5.0`, `2.0.0`, etc.)
|
|
44
|
-
*/
|
|
45
|
-
async next(baseVersion, ...opts) {
|
|
46
|
-
const latestTag = await this.githubClient.getLatestTag(...opts);
|
|
47
|
-
if (!baseVersion) {
|
|
48
|
-
if (!latestTag) {
|
|
49
|
-
return VersioningClient.INITIAL_VERSION;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const latestSemver = this.parseOrThrow("latest tag from github", latestTag);
|
|
53
|
-
return latestSemver.inc("patch").toString();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const baseVersionSemver = this.parseOrThrow("baseVersion", baseVersion);
|
|
57
|
-
if (baseVersionSemver.patch !== 0) {
|
|
58
|
-
throw new Error("baseVersion has a non-zero patch number.");
|
|
59
|
-
}
|
|
60
|
-
if (!latestTag) {
|
|
61
|
-
return baseVersionSemver.inc("patch").toString();
|
|
62
|
-
}
|
|
63
|
-
const latestSemver = this.parseOrThrow("latest tag from github", latestTag);
|
|
64
|
-
if (latestSemver.major === baseVersionSemver.major &&
|
|
65
|
-
latestSemver.minor === baseVersionSemver.minor) {
|
|
66
|
-
return latestSemver.inc("patch").toString();
|
|
67
|
-
}
|
|
68
|
-
return baseVersionSemver.toString();
|
|
69
|
-
}
|
|
70
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
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { XmlElement, XmlParser, XmlText } from "xml-trueformat";
|
|
2
|
-
import {
|
|
3
|
-
export class JavaMavenVersioningClient extends
|
|
2
|
+
import { BaseVersioningClient } from "../../base";
|
|
3
|
+
export class JavaMavenVersioningClient extends BaseVersioningClient {
|
|
4
4
|
getVersionNode(projectNode) {
|
|
5
5
|
const versionNode = projectNode.children.find((child) => child instanceof XmlElement && child.tagName === "version");
|
|
6
6
|
if (!versionNode) {
|
|
@@ -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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export class JavascriptPackageJsonVersioningClient extends
|
|
1
|
+
import { BaseVersioningClient } from "../base";
|
|
2
|
+
export class JavascriptPackageJsonVersioningClient extends BaseVersioningClient {
|
|
3
3
|
async update(version) {
|
|
4
4
|
const files = await this.findFiles("**/package.json", /(^|\/)node_modules\//);
|
|
5
5
|
for (const fileLocation of files) {
|
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum VersioningStrategy {
|
|
2
2
|
JSTS = 0,
|
|
3
3
|
JAVA_MAVEN = 1
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
5
|
+
export interface IVersioningClient {
|
|
6
6
|
update(version: string): Promise<void>;
|
|
7
7
|
}
|
|
8
|
-
export interface
|
|
9
|
-
/**
|
|
10
|
-
* generate next version tag.
|
|
11
|
-
*
|
|
12
|
-
* If `baseVersion` is not passed in:
|
|
13
|
-
* - if the repository has no tags, it will return `1.0.0`
|
|
14
|
-
* - otherwise, it will bump the latest tag's patch number
|
|
15
|
-
*
|
|
16
|
-
* if `baseVersion` is passed in, it will consult the github client and do the following:
|
|
17
|
-
*
|
|
18
|
-
* - if the github client reports a latest tag with the same `MAJOR` and `MINOR` version as `baseVersion`, it will just bump `PATCH` number
|
|
19
|
-
* - if the github client reports a latest tag with a lower `MAJOR` and `MINOR` version than `baseVersion`, it will match `baseVersion`'s `MAJOR` & `MINOR` + bump `PATCH` number
|
|
20
|
-
*
|
|
21
|
-
* `baseVersion` must set patch number to `0`. (e.g. `1.0.0`, `1.5.0`, `2.0.0`, etc.)
|
|
22
|
-
*/
|
|
23
|
-
next(baseVersion?: string): Promise<string>;
|
|
8
|
+
export interface IJavascriptPackageJsonVersioningClient extends IVersioningClient {
|
|
24
9
|
}
|
|
25
|
-
export interface
|
|
26
|
-
}
|
|
27
|
-
export interface IJavaMavenVersionUpdatingClient extends IVersionUpdatingClient {
|
|
10
|
+
export interface IJavaMavenVersioningClient extends IVersioningClient {
|
|
28
11
|
}
|
package/dist/versioning/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export var
|
|
2
|
-
(function (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})(
|
|
1
|
+
export var VersioningStrategy;
|
|
2
|
+
(function (VersioningStrategy) {
|
|
3
|
+
VersioningStrategy[VersioningStrategy["JSTS"] = 0] = "JSTS";
|
|
4
|
+
VersioningStrategy[VersioningStrategy["JAVA_MAVEN"] = 1] = "JAVA_MAVEN";
|
|
5
|
+
})(VersioningStrategy || (VersioningStrategy = {}));
|
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.56
|
|
6
|
+
"version": "1.0.56",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { IJavaMavenVersionUpdatingClient } from "../../../types";
|
|
2
|
-
import { BaseVersionUpdatingClient } from "../../base";
|
|
3
|
-
export declare class JavaMavenVersioningClient extends BaseVersionUpdatingClient implements IJavaMavenVersionUpdatingClient {
|
|
4
|
-
private getVersionNode;
|
|
5
|
-
update(version: string): Promise<void>;
|
|
6
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { IJavascriptPackageJsonVersionUpdatingClient } from "../../types";
|
|
2
|
-
import { BaseVersionUpdatingClient } from "../base";
|
|
3
|
-
export declare class JavascriptPackageJsonVersioningClient extends BaseVersionUpdatingClient implements IJavascriptPackageJsonVersionUpdatingClient {
|
|
4
|
-
update(version: string): Promise<void>;
|
|
5
|
-
}
|