@tahminator/pipeline 1.0.62 → 1.0.63

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,8 +1,17 @@
1
1
  import { EnvClientStrategy, type EnvClientReadOpts } from "./types";
2
+ export type EnvClientOpts = {
3
+ /**
4
+ * Skip GitHub Actions secret masking. Defaults to `false`.
5
+ *
6
+ * **NOTE**: Be very careful if you set this to `true`!
7
+ */
8
+ skipMasking?: boolean;
9
+ };
2
10
  export declare class EnvClient {
3
11
  private readonly strategy;
12
+ private readonly opts;
4
13
  private constructor();
5
- static create(strategy: EnvClientStrategy): EnvClient;
14
+ static create(strategy: EnvClientStrategy, opts?: EnvClientOpts): EnvClient;
6
15
  readFromEnv(fileName: string, opts?: EnvClientReadOpts): Promise<Record<string, string>>;
7
16
  private maskAndReturnEnv;
8
17
  }
@@ -2,23 +2,28 @@ import { SopsEnvClientStrategy, GitCryptEnvClientStrategy, } from "./strategy";
2
2
  import { EnvClientStrategy } from "./types";
3
3
  export class EnvClient {
4
4
  strategy;
5
- constructor(strategy) {
5
+ opts;
6
+ constructor(strategy, opts) {
6
7
  this.strategy = strategy;
8
+ this.opts = opts;
7
9
  }
8
- static create(strategy) {
10
+ static create(strategy, opts = {
11
+ skipMasking: false,
12
+ }) {
9
13
  switch (strategy) {
10
14
  case EnvClientStrategy.SOPS:
11
- return new this(new SopsEnvClientStrategy());
15
+ return new this(new SopsEnvClientStrategy(), opts);
12
16
  case EnvClientStrategy.GIT_CRYPT:
13
- return new this(new GitCryptEnvClientStrategy());
17
+ return new this(new GitCryptEnvClientStrategy(), opts);
14
18
  }
15
19
  }
16
20
  async readFromEnv(fileName, opts) {
17
21
  return this.maskAndReturnEnv(await this.strategy.readFromEnv(fileName, opts));
18
22
  }
19
23
  maskAndReturnEnv(envs) {
20
- if (process.env.CI !== "true") {
21
- return Object.fromEntries(envs);
24
+ const r = Object.fromEntries(envs);
25
+ if (this.opts.skipMasking) {
26
+ return r;
22
27
  }
23
28
  for (const [varName, value] of envs.entries()) {
24
29
  if (value === "true" || value === "false" || value === "") {
@@ -38,6 +43,6 @@ export class EnvClient {
38
43
  }
39
44
  }
40
45
  }
41
- return Object.fromEntries(envs);
46
+ return r;
42
47
  }
43
48
  }
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.62",
6
+ "version": "1.0.63",
7
7
  "repository": {
8
8
  "url": "git+https://github.com/tahminator/pipeline.git"
9
9
  },