@tahminator/pipeline 1.0.52-beta.3f43a4ea → 1.0.52-beta.411e9315

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.
@@ -11,7 +11,7 @@ export declare class PulumiClient {
11
11
  up(): Promise<UpResult>;
12
12
  preview(opts: {
13
13
  diff: boolean;
14
- rewriteStdoutToColorizedHtml: boolean;
14
+ rewriteStdoutToDiffFriendly: boolean;
15
15
  }): Promise<PreviewResult>;
16
16
  refresh(): Promise<RefreshResult>;
17
17
  static parseChangeSumaryToPrettyTable(changeSummary: OpMap): string;
@@ -3,7 +3,7 @@ export interface IPulumiClientStrategy {
3
3
  up(): Promise<UpResult>;
4
4
  preview(opts: {
5
5
  diff: boolean;
6
- rewriteStdoutToColorizedHtml: boolean;
6
+ rewriteStdoutToDiffFriendly: boolean;
7
7
  }): Promise<PreviewResult>;
8
8
  refresh(): Promise<RefreshResult>;
9
9
  }
@@ -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
- rewriteStdoutToColorizedHtml: boolean;
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,23 +20,49 @@ export class LocalWorkspacePulumiClientStrategy {
22
20
  });
23
21
  }
24
22
  async preview(args) {
25
- const { diff, rewriteStdoutToColorizedHtml: colorizedHtml } = args ?? {
23
+ const { diff, rewriteStdoutToDiffFriendly } = args ?? {
26
24
  diff: false,
27
- rewriteStdoutToColorizedHtml: false,
25
+ rewriteStdoutToDiffFriendly: false,
28
26
  };
29
27
  const previewResult = await this.stack.preview({
30
- color: colorizedHtml ? "always" : "never",
28
+ color: "never",
31
29
  refresh: false,
32
30
  diff,
33
31
  });
34
- console.log("old stdout", previewResult.stdout);
35
- const stdout = this.htmlToAnsiConverter.toHtml(previewResult.stdout);
36
- console.log("new stdout", stdout);
32
+ console.log("old stdout");
33
+ console.log(previewResult.stdout);
34
+ console.log();
35
+ const stdout = rewriteStdoutToDiffFriendly ?
36
+ this.rewritePulumiPreviewAsDiffFriendlyText(previewResult.stdout)
37
+ : previewResult.stdout;
38
+ console.log("new stdout");
39
+ console.log(stdout);
40
+ console.log();
37
41
  return {
38
42
  ...previewResult,
39
43
  stdout,
40
44
  };
41
45
  }
46
+ rewritePulumiPreviewAsDiffFriendlyText(stdout) {
47
+ return stdout
48
+ .split("\n")
49
+ .map((line) => {
50
+ if (!line) {
51
+ return line;
52
+ }
53
+ const trimmed = line.trimStart();
54
+ const symbol = trimmed.startsWith("+-") ? "!"
55
+ : trimmed.startsWith("+") ? "+"
56
+ : trimmed.startsWith("-") ? "-"
57
+ : trimmed.startsWith("~") ? "~"
58
+ : null;
59
+ if (!symbol) {
60
+ return line;
61
+ }
62
+ return symbol + line.slice(1);
63
+ })
64
+ .join("\n");
65
+ }
42
66
  async refresh() {
43
67
  return this.stack.refresh({
44
68
  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.52-beta.3f43a4ea",
6
+ "version": "1.0.52-beta.411e9315",
7
7
  "repository": {
8
8
  "url": "git+https://github.com/tahminator/pipeline.git"
9
9
  },