@tahminator/pipeline 1.0.49 → 1.0.51-beta.52b434fc
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/README.md +5 -0
- package/dist/gh/client.d.ts +2 -0
- package/dist/gh/client.js +4 -0
- package/dist/gh/tag/index.d.ts +7 -1
- package/dist/gh/tag/index.js +31 -21
- package/dist/internal/upload-npm/beta/index.d.ts +1 -0
- package/dist/internal/upload-npm/beta/index.js +40 -0
- package/dist/npm/client.d.ts +1 -1
- package/dist/npm/client.js +3 -2
- package/dist/pulumi/client.d.ts +3 -1
- package/dist/pulumi/client.js +3 -0
- package/dist/pulumi/strategy/types.d.ts +3 -1
- package/dist/pulumi/strategy/workspace.d.ts +2 -0
- package/dist/pulumi/strategy/workspace.js +12 -3
- package/dist/utils/client.d.ts +2 -0
- package/dist/utils/client.js +2 -0
- package/dist/utils/semver.d.ts +4 -0
- package/dist/utils/semver.js +6 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -156,6 +156,11 @@ await npm.publish();
|
|
|
156
156
|
|
|
157
157
|
// dry run
|
|
158
158
|
await npm.publish(true);
|
|
159
|
+
|
|
160
|
+
// publish to the beta dist-tag instead of latest
|
|
161
|
+
// just like before, you should use `Utils.updateAllPackageJsonsWithVersion`
|
|
162
|
+
// with `Utils.SemVar.validate(betaTag)` to set a valid version
|
|
163
|
+
await npm.publish(false, true);
|
|
159
164
|
```
|
|
160
165
|
|
|
161
166
|
### `SonarScannerClient`
|
package/dist/gh/client.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { GitHubTagManager } from "./tag";
|
|
|
4
4
|
export declare class GitHubClient {
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly isExplicitToken;
|
|
7
|
+
static readonly BASE_VERSION = "1.0.0";
|
|
7
8
|
private readonly tagManager;
|
|
8
9
|
private readonly outputManager;
|
|
9
10
|
private readonly prManager;
|
|
@@ -35,6 +36,7 @@ export declare class GitHubClient {
|
|
|
35
36
|
*/
|
|
36
37
|
static createWithPatCiToken(pat: string): Promise<GitHubClient>;
|
|
37
38
|
createTag(...args: Parameters<GitHubTagManager["createTag"]>): Promise<void>;
|
|
39
|
+
getLatestTag(...args: Parameters<GitHubTagManager["getLatestTag"]>): Promise<string | null>;
|
|
38
40
|
outputToGithubOutput(...args: Parameters<GitHubOutputManager["outputToGithubOutput"]>): Promise<void>;
|
|
39
41
|
updateK8sTagWithPR(...args: Parameters<GitHubPRManager["updateK8sTagWithPR"]>): Promise<void>;
|
|
40
42
|
sendPrMessage(...args: Parameters<GitHubPRManager["sendPrMessage"]>): Promise<void>;
|
package/dist/gh/client.js
CHANGED
|
@@ -6,6 +6,7 @@ import { GitHubTagManager } from "./tag";
|
|
|
6
6
|
export class GitHubClient {
|
|
7
7
|
client;
|
|
8
8
|
isExplicitToken;
|
|
9
|
+
static BASE_VERSION = GitHubTagManager.BASE_VERSION;
|
|
9
10
|
tagManager;
|
|
10
11
|
outputManager;
|
|
11
12
|
prManager;
|
|
@@ -56,6 +57,9 @@ export class GitHubClient {
|
|
|
56
57
|
createTag(...args) {
|
|
57
58
|
return this.tagManager.createTag(...args);
|
|
58
59
|
}
|
|
60
|
+
getLatestTag(...args) {
|
|
61
|
+
return this.tagManager.getLatestTag(...args);
|
|
62
|
+
}
|
|
59
63
|
outputToGithubOutput(...args) {
|
|
60
64
|
return this.outputManager.outputToGithubOutput(...args);
|
|
61
65
|
}
|
package/dist/gh/tag/index.d.ts
CHANGED
|
@@ -4,9 +4,15 @@ import type { OwnerString, RepoString } from "../../types";
|
|
|
4
4
|
export declare class GitHubTagManager {
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly isExplicitToken;
|
|
7
|
-
|
|
7
|
+
static readonly BASE_VERSION = "1.0.0";
|
|
8
8
|
constructor(client: Octokit, isExplicitToken: boolean);
|
|
9
9
|
private checkToken;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the latest stable semver tag in the repository.
|
|
12
|
+
*/
|
|
13
|
+
getLatestTag({ repositoryOverride, }?: {
|
|
14
|
+
repositoryOverride?: [OwnerString, RepoString];
|
|
15
|
+
}): Promise<string | null>;
|
|
10
16
|
/**
|
|
11
17
|
* Utilizes the GitHub API to create a new tag version in the given repository.
|
|
12
18
|
*
|
package/dist/gh/tag/index.js
CHANGED
|
@@ -14,6 +14,23 @@ export class GitHubTagManager {
|
|
|
14
14
|
throw new Error("You must pass in an explicit GitHub token for this operation. You may either use a PAT or a GitHub App Token");
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the latest stable semver tag in the repository.
|
|
19
|
+
*/
|
|
20
|
+
async getLatestTag({ repositoryOverride, } = {}) {
|
|
21
|
+
const [owner, repo] = this.parseRepository(repositoryOverride);
|
|
22
|
+
const { data: tags } = await this.client.rest.repos.listTags({
|
|
23
|
+
owner,
|
|
24
|
+
repo,
|
|
25
|
+
});
|
|
26
|
+
return (tags
|
|
27
|
+
.map((t) => t.name)
|
|
28
|
+
.filter((tag) => {
|
|
29
|
+
const parsed = semver.parse(tag);
|
|
30
|
+
return parsed && parsed.prerelease.length === 0;
|
|
31
|
+
})
|
|
32
|
+
.sort(semver.rcompare)[0] ?? null);
|
|
33
|
+
}
|
|
17
34
|
/**
|
|
18
35
|
* Utilizes the GitHub API to create a new tag version in the given repository.
|
|
19
36
|
*
|
|
@@ -23,19 +40,10 @@ export class GitHubTagManager {
|
|
|
23
40
|
*/
|
|
24
41
|
async createTag({ repositoryOverride, releaseType, onPreTagCreate, }) {
|
|
25
42
|
this.checkToken();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})();
|
|
30
|
-
const [owner, repo] = this.parseRepository(repositoryOverride, repositoryEnv)();
|
|
31
|
-
const { data: tags } = await this.client.rest.repos.listTags({
|
|
32
|
-
owner,
|
|
33
|
-
repo,
|
|
43
|
+
const [owner, repo] = this.parseRepository(repositoryOverride);
|
|
44
|
+
const lastTag = await this.getLatestTag({
|
|
45
|
+
repositoryOverride: [owner, repo],
|
|
34
46
|
});
|
|
35
|
-
const lastTag = tags
|
|
36
|
-
.map((t) => t.name)
|
|
37
|
-
.filter((v) => semver.valid(v))
|
|
38
|
-
.sort(semver.rcompare)[0];
|
|
39
47
|
const nextTag = lastTag ?
|
|
40
48
|
semver.inc(lastTag, releaseType ?? "patch")
|
|
41
49
|
: GitHubTagManager.BASE_VERSION;
|
|
@@ -80,16 +88,18 @@ export class GitHubTagManager {
|
|
|
80
88
|
sha: commit.sha,
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
|
-
parseRepository(repositoryOverride
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
parseRepository(repositoryOverride) {
|
|
92
|
+
if (repositoryOverride) {
|
|
93
|
+
return [repositoryOverride[0], repositoryOverride[1]];
|
|
94
|
+
}
|
|
95
|
+
const repositoryEnv = (() => {
|
|
96
|
+
const v = process.env.GITHUB_REPOSITORY;
|
|
97
|
+
return v;
|
|
98
|
+
})();
|
|
99
|
+
if (!repositoryEnv) {
|
|
91
100
|
throw new Error("GITHUB_REPOSITORY not found in environment and no explicit github repository override defined");
|
|
92
|
-
}
|
|
101
|
+
}
|
|
102
|
+
return repositoryEnv.split("/");
|
|
93
103
|
}
|
|
94
104
|
async createBlob({ owner, repo, baseSha, changedFiles, }) {
|
|
95
105
|
if (!changedFiles.length) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import yargs from "yargs";
|
|
2
|
+
import { hideBin } from "yargs/helpers";
|
|
3
|
+
import { GitHubClient } from "../../../gh";
|
|
4
|
+
import { NPMClient } from "../../../npm";
|
|
5
|
+
import { Utils } from "../../../utils";
|
|
6
|
+
const { sha } = await yargs(hideBin(process.argv))
|
|
7
|
+
.option("sha", {
|
|
8
|
+
type: "string",
|
|
9
|
+
demandOption: true,
|
|
10
|
+
})
|
|
11
|
+
.strict()
|
|
12
|
+
.parse();
|
|
13
|
+
async function main() {
|
|
14
|
+
const ghClient = await GitHubClient.createWithDefaultCiToken();
|
|
15
|
+
const npmClient = await NPMClient.create();
|
|
16
|
+
const shortSha = await getShortSha(sha);
|
|
17
|
+
const lastTag = (await ghClient.getLatestTag()) ?? GitHubClient.BASE_VERSION;
|
|
18
|
+
const betaVersion = `${lastTag}-beta.${shortSha}`;
|
|
19
|
+
if (!Utils.SemVer.validate(betaVersion)) {
|
|
20
|
+
throw new Error(`Generated invalid beta version: ${betaVersion}`);
|
|
21
|
+
}
|
|
22
|
+
await Utils.updateAllPackageJsonsWithVersion(betaVersion);
|
|
23
|
+
await npmClient.publish(false, true);
|
|
24
|
+
console.log(`Uploaded ${betaVersion} to NPM.`);
|
|
25
|
+
}
|
|
26
|
+
async function getShortSha(sha) {
|
|
27
|
+
const shortSha = sha.slice(0, 8).toString().trim();
|
|
28
|
+
if (shortSha.length !== 8) {
|
|
29
|
+
throw new Error("Could not parse git SHA");
|
|
30
|
+
}
|
|
31
|
+
return shortSha;
|
|
32
|
+
}
|
|
33
|
+
main()
|
|
34
|
+
.then(() => {
|
|
35
|
+
process.exit(0);
|
|
36
|
+
})
|
|
37
|
+
.catch((e) => {
|
|
38
|
+
console.error(e);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
});
|
package/dist/npm/client.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class NPMClient {
|
|
|
18
18
|
* is filled out with the name of the package and the version you would like to
|
|
19
19
|
* deploy.
|
|
20
20
|
*/
|
|
21
|
-
publish(dryRun?: boolean): Promise<void>;
|
|
21
|
+
publish(dryRun?: boolean, publishBetaTag?: boolean): Promise<void>;
|
|
22
22
|
[Symbol.asyncDispose](): Promise<void>;
|
|
23
23
|
cleanup(): Promise<void>;
|
|
24
24
|
}
|
package/dist/npm/client.js
CHANGED
|
@@ -23,15 +23,16 @@ export class NPMClient {
|
|
|
23
23
|
* is filled out with the name of the package and the version you would like to
|
|
24
24
|
* deploy.
|
|
25
25
|
*/
|
|
26
|
-
async publish(dryRun) {
|
|
26
|
+
async publish(dryRun, publishBetaTag) {
|
|
27
27
|
const dryRunFlag = dryRun ? ["--dry-run"] : [];
|
|
28
|
+
const tagFlag = publishBetaTag ? ["--tag", "beta"] : [];
|
|
28
29
|
if (Utils.Log.isDebug) {
|
|
29
30
|
console.log(await $ `ls .`.text());
|
|
30
31
|
console.log(await $ `ls ./dist/`.text());
|
|
31
32
|
console.log(await $ `pwd`.text());
|
|
32
33
|
console.log(await $ `cat ./package.json`.text());
|
|
33
34
|
}
|
|
34
|
-
await $ `npm publish --access public --provenance ${dryRunFlag} ./`;
|
|
35
|
+
await $ `npm publish --access public --provenance ${tagFlag} ${dryRunFlag} ./`;
|
|
35
36
|
console.log("Package has been successfully published");
|
|
36
37
|
}
|
|
37
38
|
async [Symbol.asyncDispose]() {
|
package/dist/pulumi/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OpMap, OpType, PreviewResult, UpResult } from "@pulumi/pulumi/automation";
|
|
1
|
+
import type { OpMap, OpType, PreviewResult, RefreshResult, UpResult } from "@pulumi/pulumi/automation";
|
|
2
2
|
import { type PulumiClientCreateArgs } from "./types";
|
|
3
3
|
export declare class PulumiClient {
|
|
4
4
|
private readonly strategy;
|
|
@@ -11,6 +11,8 @@ export declare class PulumiClient {
|
|
|
11
11
|
up(): Promise<UpResult>;
|
|
12
12
|
preview(opts: {
|
|
13
13
|
diff: boolean;
|
|
14
|
+
rewriteStdoutToColorizedHtml: boolean;
|
|
14
15
|
}): Promise<PreviewResult>;
|
|
16
|
+
refresh(): Promise<RefreshResult>;
|
|
15
17
|
static parseChangeSumaryToPrettyTable(changeSummary: OpMap): string;
|
|
16
18
|
}
|
package/dist/pulumi/client.js
CHANGED
|
@@ -37,6 +37,9 @@ export class PulumiClient {
|
|
|
37
37
|
async preview(opts) {
|
|
38
38
|
return this.strategy.preview(opts);
|
|
39
39
|
}
|
|
40
|
+
async refresh() {
|
|
41
|
+
return this.strategy.refresh();
|
|
42
|
+
}
|
|
40
43
|
static parseChangeSumaryToPrettyTable(changeSummary) {
|
|
41
44
|
const entries = Object.entries(changeSummary).filter(([_, count]) => count > 0);
|
|
42
45
|
if (entries.length === 0) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { PreviewResult, UpResult } from "@pulumi/pulumi/automation";
|
|
1
|
+
import type { PreviewResult, RefreshResult, UpResult } from "@pulumi/pulumi/automation";
|
|
2
2
|
export interface IPulumiClientStrategy {
|
|
3
3
|
up(): Promise<UpResult>;
|
|
4
4
|
preview(opts: {
|
|
5
5
|
diff: boolean;
|
|
6
|
+
rewriteStdoutToColorizedHtml: boolean;
|
|
6
7
|
}): Promise<PreviewResult>;
|
|
8
|
+
refresh(): Promise<RefreshResult>;
|
|
7
9
|
}
|
|
@@ -3,11 +3,13 @@ import type { PulumiClientCreateArgs } from "../types";
|
|
|
3
3
|
import type { IPulumiClientStrategy } from "./types";
|
|
4
4
|
export declare class LocalWorkspacePulumiClientStrategy implements IPulumiClientStrategy {
|
|
5
5
|
private readonly stack;
|
|
6
|
+
private readonly htmlToAnsiConverter;
|
|
6
7
|
private constructor();
|
|
7
8
|
static create(args: PulumiClientCreateArgs): Promise<LocalWorkspacePulumiClientStrategy>;
|
|
8
9
|
up(): Promise<UpResult>;
|
|
9
10
|
preview(args: {
|
|
10
11
|
diff: boolean;
|
|
12
|
+
rewriteStdoutToColorizedHtml: boolean;
|
|
11
13
|
} | undefined): Promise<PreviewResult>;
|
|
12
14
|
refresh(): Promise<RefreshResult>;
|
|
13
15
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { LocalWorkspace, } from "@pulumi/pulumi/automation";
|
|
2
|
+
import Convert from "ansi-to-html";
|
|
2
3
|
export class LocalWorkspacePulumiClientStrategy {
|
|
3
4
|
stack;
|
|
5
|
+
htmlToAnsiConverter = new Convert();
|
|
4
6
|
constructor(stack) {
|
|
5
7
|
this.stack = stack;
|
|
6
8
|
}
|
|
@@ -20,12 +22,19 @@ export class LocalWorkspacePulumiClientStrategy {
|
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
async preview(args) {
|
|
23
|
-
const { diff } = args ?? {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const { diff, rewriteStdoutToColorizedHtml: colorizedHtml } = args ?? {
|
|
26
|
+
diff: false,
|
|
27
|
+
rewriteStdoutToColorizedHtml: false,
|
|
28
|
+
};
|
|
29
|
+
const previewResult = await this.stack.preview({
|
|
30
|
+
color: colorizedHtml ? "always" : "never",
|
|
26
31
|
refresh: false,
|
|
27
32
|
diff,
|
|
28
33
|
});
|
|
34
|
+
return {
|
|
35
|
+
...previewResult,
|
|
36
|
+
stdout: this.htmlToAnsiConverter.toHtml(previewResult.stdout),
|
|
37
|
+
};
|
|
29
38
|
}
|
|
30
39
|
async refresh() {
|
|
31
40
|
return this.stack.refresh({
|
package/dist/utils/client.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { decodeBase64EncodedString } from "./b64";
|
|
|
2
2
|
import { isCmdAvailable } from "./cmd";
|
|
3
3
|
import { Colors } from "./colors";
|
|
4
4
|
import { Log } from "./log";
|
|
5
|
+
import { SemVer } from "./semver";
|
|
5
6
|
import { generateShortId } from "./short";
|
|
6
7
|
export declare class Utils {
|
|
7
8
|
static Colors: typeof Colors;
|
|
8
9
|
static Log: typeof Log;
|
|
10
|
+
static SemVer: typeof SemVer;
|
|
9
11
|
static generateShortId(...args: Parameters<typeof generateShortId>): string;
|
|
10
12
|
static updateAllPackageJsonsWithVersion(version: string): Promise<void>;
|
|
11
13
|
static isCmdAvailable(...args: Parameters<typeof isCmdAvailable>): Promise<boolean>;
|
package/dist/utils/client.js
CHANGED
|
@@ -3,11 +3,13 @@ import { decodeBase64EncodedString } from "./b64";
|
|
|
3
3
|
import { isCmdAvailable } from "./cmd";
|
|
4
4
|
import { Colors } from "./colors";
|
|
5
5
|
import { Log } from "./log";
|
|
6
|
+
import { SemVer } from "./semver";
|
|
6
7
|
import { generateShortId } from "./short";
|
|
7
8
|
export class Utils {
|
|
8
9
|
// hoist
|
|
9
10
|
static Colors = Colors;
|
|
10
11
|
static Log = Log;
|
|
12
|
+
static SemVer = SemVer;
|
|
11
13
|
static generateShortId(...args) {
|
|
12
14
|
return generateShortId(...args);
|
|
13
15
|
}
|
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.51-beta.52b434fc",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@eslint/js": "^10.0.1",
|
|
36
36
|
"@types/bun": "latest",
|
|
37
|
+
"@types/semver": "^7.7.1",
|
|
38
|
+
"@types/yargs": "^17.0.35",
|
|
37
39
|
"eslint": "^10.0.3",
|
|
38
40
|
"eslint-plugin-perfectionist": "^5.7.0",
|
|
39
41
|
"globals": "^17.4.0",
|
|
40
42
|
"jiti": "^2.6.1",
|
|
41
43
|
"prettier": "^3.8.1",
|
|
42
44
|
"typescript-eslint": "^8.57.1",
|
|
43
|
-
"vitest": "^4.1.0"
|
|
44
|
-
"@types/semver": "^7.7.1",
|
|
45
|
-
"@types/yargs": "^17.0.35"
|
|
45
|
+
"vitest": "^4.1.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"typescript": "^5"
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@octokit/auth-app": "^8.2.0",
|
|
52
52
|
"@octokit/rest": "^22.0.1",
|
|
53
53
|
"@pulumi/pulumi": "^3.230.0",
|
|
54
|
+
"ansi-to-html": "^0.7.2",
|
|
54
55
|
"neverthrow": "^8.2.0",
|
|
55
56
|
"semver": "^7.7.4",
|
|
56
57
|
"yaml": "^2.8.2",
|