@tahminator/pipeline 1.0.56 → 1.0.57
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/client.d.ts +21 -2
- package/dist/versioning/client.js +56 -6
- package/dist/versioning/types.d.ts +21 -4
- package/dist/versioning/types.js +5 -5
- package/dist/versioning/{base.d.ts → updating/base.d.ts} +2 -2
- package/dist/versioning/{base.js → updating/base.js} +1 -1
- package/dist/versioning/updating/java/maven/index.d.ts +6 -0
- package/dist/versioning/{java → updating/java}/maven/index.js +2 -2
- package/dist/versioning/updating/jsts/index.d.ts +5 -0
- package/dist/versioning/{jsts → updating/jsts}/index.js +2 -2
- package/package.json +1 -1
- package/dist/versioning/java/maven/index.d.ts +0 -6
- package/dist/versioning/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 { VersionUpdatingStrategy } 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(ghClient, VersionUpdatingStrategy.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,7 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GitHubClient } from "../gh";
|
|
2
|
+
import { VersionUpdatingStrategy, type IVersioningClient } from "./types";
|
|
2
3
|
export declare class VersioningClient implements IVersioningClient {
|
|
4
|
+
private readonly githubClient;
|
|
5
|
+
private static readonly INITIAL_VERSION;
|
|
3
6
|
private readonly delegate;
|
|
4
|
-
constructor(strategy:
|
|
7
|
+
constructor(githubClient: GitHubClient, strategy: VersionUpdatingStrategy);
|
|
5
8
|
private getDelegate;
|
|
9
|
+
private parseOrThrow;
|
|
6
10
|
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>;
|
|
7
26
|
}
|
|
@@ -1,20 +1,70 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
import { VersionUpdatingStrategy, } from "./types";
|
|
3
|
+
import { JavaMavenVersioningClient } from "./updating/java/maven";
|
|
4
|
+
import { JavascriptPackageJsonVersioningClient } from "./updating/jsts";
|
|
4
5
|
export class VersioningClient {
|
|
6
|
+
githubClient;
|
|
7
|
+
static INITIAL_VERSION = "1.0.0";
|
|
5
8
|
delegate;
|
|
6
|
-
constructor(strategy) {
|
|
9
|
+
constructor(githubClient, strategy) {
|
|
10
|
+
this.githubClient = githubClient;
|
|
7
11
|
this.delegate = this.getDelegate(strategy);
|
|
8
12
|
}
|
|
9
13
|
getDelegate(strategy) {
|
|
10
14
|
switch (strategy) {
|
|
11
|
-
case
|
|
15
|
+
case VersionUpdatingStrategy.JSTS:
|
|
12
16
|
return new JavascriptPackageJsonVersioningClient();
|
|
13
|
-
case
|
|
17
|
+
case VersionUpdatingStrategy.JAVA_MAVEN:
|
|
14
18
|
return new JavaMavenVersioningClient();
|
|
15
19
|
}
|
|
16
20
|
}
|
|
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
|
+
}
|
|
17
28
|
async update(version) {
|
|
18
29
|
await this.delegate.update(version);
|
|
19
30
|
}
|
|
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
|
+
}
|
|
20
70
|
}
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum VersionUpdatingStrategy {
|
|
2
2
|
JSTS = 0,
|
|
3
3
|
JAVA_MAVEN = 1
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
5
|
+
export interface IVersionUpdatingClient {
|
|
6
6
|
update(version: string): Promise<void>;
|
|
7
7
|
}
|
|
8
|
-
export interface
|
|
8
|
+
export interface IVersioningClient extends IVersionUpdatingClient {
|
|
9
|
+
/**
|
|
10
|
+
* generate next version tag.
|
|
11
|
+
*
|
|
12
|
+
* If `baseVersion` is not passed in:
|
|
13
|
+
* - if the repository has no tags yet, 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`. __It will NOT 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>;
|
|
9
24
|
}
|
|
10
|
-
export interface
|
|
25
|
+
export interface IJavascriptPackageJsonVersionUpdatingClient extends IVersionUpdatingClient {
|
|
26
|
+
}
|
|
27
|
+
export interface IJavaMavenVersionUpdatingClient extends IVersionUpdatingClient {
|
|
11
28
|
}
|
package/dist/versioning/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export var
|
|
2
|
-
(function (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})(
|
|
1
|
+
export var VersionUpdatingStrategy;
|
|
2
|
+
(function (VersionUpdatingStrategy) {
|
|
3
|
+
VersionUpdatingStrategy[VersionUpdatingStrategy["JSTS"] = 0] = "JSTS";
|
|
4
|
+
VersionUpdatingStrategy[VersionUpdatingStrategy["JAVA_MAVEN"] = 1] = "JAVA_MAVEN";
|
|
5
|
+
})(VersionUpdatingStrategy || (VersionUpdatingStrategy = {}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare abstract class
|
|
1
|
+
import type { IVersionUpdatingClient } from "../types";
|
|
2
|
+
export declare abstract class BaseVersionUpdatingClient implements IVersionUpdatingClient {
|
|
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[]>;
|
|
@@ -0,0 +1,6 @@
|
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { XmlElement, XmlParser, XmlText } from "xml-trueformat";
|
|
2
|
-
import {
|
|
3
|
-
export class JavaMavenVersioningClient extends
|
|
2
|
+
import { BaseVersionUpdatingClient } from "../../base";
|
|
3
|
+
export class JavaMavenVersioningClient extends BaseVersionUpdatingClient {
|
|
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 { IJavascriptPackageJsonVersionUpdatingClient } from "../../types";
|
|
2
|
+
import { BaseVersionUpdatingClient } from "../base";
|
|
3
|
+
export declare class JavascriptPackageJsonVersioningClient extends BaseVersionUpdatingClient implements IJavascriptPackageJsonVersionUpdatingClient {
|
|
4
|
+
update(version: string): Promise<void>;
|
|
5
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export class JavascriptPackageJsonVersioningClient extends
|
|
1
|
+
import { BaseVersionUpdatingClient } from "../base";
|
|
2
|
+
export class JavascriptPackageJsonVersioningClient extends BaseVersionUpdatingClient {
|
|
3
3
|
async update(version) {
|
|
4
4
|
const files = await this.findFiles("**/package.json", /(^|\/)node_modules\//);
|
|
5
5
|
for (const fileLocation of files) {
|
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.57",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|
|
@@ -1,6 +0,0 @@
|
|
|
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,5 +0,0 @@
|
|
|
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
|
-
}
|