@tahminator/pipeline 1.0.52 → 1.0.53
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.
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import yargs from "yargs";
|
|
2
2
|
import { hideBin } from "yargs/helpers";
|
|
3
|
+
import { EnvClient, EnvClientStrategy } from "../../../env";
|
|
3
4
|
import { GitHubClient } from "../../../gh";
|
|
4
5
|
import { NPMClient } from "../../../npm";
|
|
5
6
|
import { Utils } from "../../../utils";
|
|
6
|
-
const { sha } = await yargs(hideBin(process.argv))
|
|
7
|
+
const { sha, prId } = await yargs(hideBin(process.argv))
|
|
7
8
|
.option("sha", {
|
|
8
9
|
type: "string",
|
|
9
10
|
demandOption: true,
|
|
11
|
+
})
|
|
12
|
+
.option("prId", {
|
|
13
|
+
type: "number",
|
|
14
|
+
demandOption: true,
|
|
10
15
|
})
|
|
11
16
|
.strict()
|
|
12
17
|
.parse();
|
|
13
18
|
async function main() {
|
|
14
|
-
const
|
|
19
|
+
const envClient = EnvClient.create(EnvClientStrategy.GIT_CRYPT);
|
|
20
|
+
const { githubAppAppId, githubAppInstallationId, githubAppPrivateKeyB64 } = parseCiEnv(await envClient.readFromEnv(".env.ci"));
|
|
21
|
+
const ghClient = await GitHubClient.createWithGithubAppToken({
|
|
22
|
+
appId: githubAppAppId,
|
|
23
|
+
installationId: githubAppInstallationId,
|
|
24
|
+
privateKey: await Utils.decodeBase64EncodedString(githubAppPrivateKeyB64),
|
|
25
|
+
});
|
|
15
26
|
const npmClient = await NPMClient.create();
|
|
16
27
|
const shortSha = await getShortSha(sha);
|
|
17
28
|
const lastTag = (await ghClient.getLatestTag()) ?? GitHubClient.BASE_VERSION;
|
|
@@ -22,6 +33,16 @@ async function main() {
|
|
|
22
33
|
await Utils.updateAllPackageJsonsWithVersion(betaVersion);
|
|
23
34
|
await npmClient.publish(false, true);
|
|
24
35
|
console.log(`Uploaded ${betaVersion} to NPM.`);
|
|
36
|
+
await ghClient.sendPrMessage({
|
|
37
|
+
prId,
|
|
38
|
+
owner: "tahminator",
|
|
39
|
+
repository: "pipeline",
|
|
40
|
+
message: `
|
|
41
|
+
## Test Version Uploaded
|
|
42
|
+
|
|
43
|
+
Uploaded ${betaVersion} to NPM. View version on NPM registry [here](https://www.npmjs.com/package/@tahminator/pipeline/v/${betaVersion}).
|
|
44
|
+
`,
|
|
45
|
+
});
|
|
25
46
|
}
|
|
26
47
|
async function getShortSha(sha) {
|
|
27
48
|
const shortSha = sha.slice(0, 8).toString().trim();
|
|
@@ -30,6 +51,30 @@ async function getShortSha(sha) {
|
|
|
30
51
|
}
|
|
31
52
|
return shortSha;
|
|
32
53
|
}
|
|
54
|
+
function parseCiEnv(ciEnv) {
|
|
55
|
+
const githubAppAppId = (() => {
|
|
56
|
+
const v = ciEnv["GITHUB_APP_APP_ID"];
|
|
57
|
+
if (!v) {
|
|
58
|
+
throw new Error("Missing GITHUB_APP_APP_ID from .env.ci");
|
|
59
|
+
}
|
|
60
|
+
return v;
|
|
61
|
+
})();
|
|
62
|
+
const githubAppInstallationId = (() => {
|
|
63
|
+
const v = ciEnv["GITHUB_APP_INSTALLATION_ID"];
|
|
64
|
+
if (!v) {
|
|
65
|
+
throw new Error("Missing GITHUB_APP_INSTALLATION_ID from .env.ci");
|
|
66
|
+
}
|
|
67
|
+
return v;
|
|
68
|
+
})();
|
|
69
|
+
const githubAppPrivateKeyB64 = (() => {
|
|
70
|
+
const v = ciEnv["GITHUB_APP_PRIVATE_KEY_B64"];
|
|
71
|
+
if (!v) {
|
|
72
|
+
throw new Error("Missing GITHUB_APP_PRIVATE_KEY_B64 from .env.ci");
|
|
73
|
+
}
|
|
74
|
+
return v;
|
|
75
|
+
})();
|
|
76
|
+
return { githubAppAppId, githubAppInstallationId, githubAppPrivateKeyB64 };
|
|
77
|
+
}
|
|
33
78
|
main()
|
|
34
79
|
.then(() => {
|
|
35
80
|
process.exit(0);
|
package/dist/pulumi/client.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare class PulumiClient {
|
|
|
11
11
|
up(): Promise<UpResult>;
|
|
12
12
|
preview(opts: {
|
|
13
13
|
diff: boolean;
|
|
14
|
-
|
|
14
|
+
rewriteStdoutToDiffFriendly: boolean;
|
|
15
15
|
}): Promise<PreviewResult>;
|
|
16
16
|
refresh(): Promise<RefreshResult>;
|
|
17
17
|
static parseChangeSumaryToPrettyTable(changeSummary: OpMap): string;
|
|
@@ -3,13 +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;
|
|
7
6
|
private constructor();
|
|
8
7
|
static create(args: PulumiClientCreateArgs): Promise<LocalWorkspacePulumiClientStrategy>;
|
|
9
8
|
up(): Promise<UpResult>;
|
|
10
9
|
preview(args: {
|
|
11
10
|
diff: boolean;
|
|
12
|
-
|
|
11
|
+
rewriteStdoutToDiffFriendly: boolean;
|
|
13
12
|
} | undefined): Promise<PreviewResult>;
|
|
13
|
+
private rewritePulumiPreviewAsDiffFriendlyText;
|
|
14
14
|
refresh(): Promise<RefreshResult>;
|
|
15
15
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { LocalWorkspace, } from "@pulumi/pulumi/automation";
|
|
2
|
-
import Convert from "ansi-to-html";
|
|
3
2
|
export class LocalWorkspacePulumiClientStrategy {
|
|
4
3
|
stack;
|
|
5
|
-
htmlToAnsiConverter = new Convert();
|
|
6
4
|
constructor(stack) {
|
|
7
5
|
this.stack = stack;
|
|
8
6
|
}
|
|
@@ -22,20 +20,43 @@ export class LocalWorkspacePulumiClientStrategy {
|
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
22
|
async preview(args) {
|
|
25
|
-
const { diff,
|
|
23
|
+
const { diff, rewriteStdoutToDiffFriendly } = args ?? {
|
|
26
24
|
diff: false,
|
|
27
|
-
|
|
25
|
+
rewriteStdoutToDiffFriendly: false,
|
|
28
26
|
};
|
|
29
27
|
const previewResult = await this.stack.preview({
|
|
30
|
-
color:
|
|
28
|
+
color: "never",
|
|
31
29
|
refresh: false,
|
|
32
30
|
diff,
|
|
33
31
|
});
|
|
32
|
+
const stdout = rewriteStdoutToDiffFriendly ?
|
|
33
|
+
this.rewritePulumiPreviewAsDiffFriendlyText(previewResult.stdout)
|
|
34
|
+
: previewResult.stdout;
|
|
34
35
|
return {
|
|
35
36
|
...previewResult,
|
|
36
|
-
stdout
|
|
37
|
+
stdout,
|
|
37
38
|
};
|
|
38
39
|
}
|
|
40
|
+
rewritePulumiPreviewAsDiffFriendlyText(stdout) {
|
|
41
|
+
return stdout
|
|
42
|
+
.split("\n")
|
|
43
|
+
.map((line) => {
|
|
44
|
+
if (!line) {
|
|
45
|
+
return line;
|
|
46
|
+
}
|
|
47
|
+
const trimmed = line.trimStart();
|
|
48
|
+
const symbol = trimmed.startsWith("+-") ? "!"
|
|
49
|
+
: trimmed.startsWith("+") ? "+"
|
|
50
|
+
: trimmed.startsWith("-") ? "-"
|
|
51
|
+
: trimmed.startsWith("~") ? "!"
|
|
52
|
+
: null;
|
|
53
|
+
if (!symbol) {
|
|
54
|
+
return line;
|
|
55
|
+
}
|
|
56
|
+
return symbol + line.slice(1);
|
|
57
|
+
})
|
|
58
|
+
.join("\n");
|
|
59
|
+
}
|
|
39
60
|
async refresh() {
|
|
40
61
|
return this.stack.refresh({
|
|
41
62
|
color: "never",
|
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.53",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|