@tahminator/pipeline 1.0.19 → 1.0.21

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/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./gh";
2
2
  export * from "./docker";
3
3
  export * from "./npm";
4
+ export * from "./sonar";
4
5
  export * from "./types";
5
6
  export * from "./utils";
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./gh";
2
2
  export * from "./docker";
3
3
  export * from "./npm";
4
+ export * from "./sonar";
4
5
  export * from "./types";
5
6
  export * from "./utils";
@@ -0,0 +1,26 @@
1
+ import { $ } from "bun";
2
+ type SonarScannerOpts = {
3
+ auth: {
4
+ token: string;
5
+ };
6
+ run: {
7
+ runTestsCmd: $.ShellPromise;
8
+ };
9
+ scan: {
10
+ hostUrl?: string;
11
+ additionalArgs?: Record<string, string | number | boolean>;
12
+ projectKey: string;
13
+ organization: string;
14
+ sourceCodeDir: string;
15
+ };
16
+ };
17
+ /**
18
+ * @beta WIP
19
+ */
20
+ export declare class SonarScannerClient {
21
+ private readonly opts;
22
+ constructor(opts: SonarScannerOpts);
23
+ runTests(): Promise<void>;
24
+ uploadTests(): Promise<void>;
25
+ }
26
+ export {};
@@ -0,0 +1,30 @@
1
+ import { $ } from "bun";
2
+ import { isCmdAvailable } from "../utils/cmd";
3
+ /**
4
+ * @beta WIP
5
+ */
6
+ export class SonarScannerClient {
7
+ opts;
8
+ constructor(opts) {
9
+ this.opts = opts;
10
+ }
11
+ async runTests() {
12
+ await this.opts.run.runTestsCmd;
13
+ }
14
+ async uploadTests() {
15
+ if (!(await isCmdAvailable("sonar"))) {
16
+ console.log("Sonar is missing, installing globally via NPM...");
17
+ await $ `npm i -g @sonar/scan`;
18
+ }
19
+ const { auth, scan } = this.opts;
20
+ const args = [
21
+ `-Dsonar.host.url=${scan.hostUrl ?? "https://sonarcloud.io"}`,
22
+ `-Dsonar.token=${auth.token}`,
23
+ `-Dsonar.projectKey=${scan.projectKey}`,
24
+ `-Dsonar.organization=${scan.organization}`,
25
+ `-Dsonar.sources=${scan.sourceCodeDir}`,
26
+ ...Object.entries(scan.additionalArgs ?? {}).map(([k, v]) => `-Dsonar.${k}=${v}`),
27
+ ];
28
+ await $ `sonar ${args}`;
29
+ }
30
+ }
@@ -1,9 +1 @@
1
- /**
2
- * @beta WIP
3
- */
4
- export declare class SonarScannerClient {
5
- private readonly opts;
6
- private constructor();
7
- runTests(): Promise<void>;
8
- uploadTests(): Promise<void>;
9
- }
1
+ export * from "./client";
@@ -1,30 +1 @@
1
- import { $ } from "bun";
2
- import { isCmdAvailable } from "../utils/cmd";
3
- /**
4
- * @beta WIP
5
- */
6
- export class SonarScannerClient {
7
- opts;
8
- constructor(opts) {
9
- this.opts = opts;
10
- }
11
- async runTests() {
12
- await this.opts.run.runTestsCmd;
13
- }
14
- async uploadTests() {
15
- if (!(await isCmdAvailable("sonar"))) {
16
- console.log("Sonar is missing, installing globally via NPM...");
17
- await $ `npm i -g @sonar/scan`;
18
- }
19
- const { auth, scan } = this.opts;
20
- const args = [
21
- `-Dsonar.host.url=${scan.hostUrl ?? "https://sonarcloud.io"}`,
22
- `-Dsonar.token=${auth.token}`,
23
- `-Dsonar.projectKey=${scan.projectKey}`,
24
- `-Dsonar.organization=${scan.organization}`,
25
- `-Dsonar.sources=${scan.sourceCodeDir}`,
26
- ...Object.entries(scan.additionalArgs ?? {}).map(([k, v]) => `-Dsonar.${k}=${v}`),
27
- ];
28
- await $ `sonar ${args}`;
29
- }
30
- }
1
+ export * from "./client";
@@ -1,3 +1,4 @@
1
+ import { isCmdAvailable } from "./cmd";
1
2
  import { Colors } from "./colors";
2
3
  import { getEnvVariables } from "./env";
3
4
  import { Log } from "./log";
@@ -8,4 +9,5 @@ export declare class Utils {
8
9
  static getEnvVariables(...args: Parameters<typeof getEnvVariables>): Promise<Record<string, string>>;
9
10
  static generateShortId(...args: Parameters<typeof generateShortId>): string;
10
11
  static updateAllPackageJsonsWithVersion(version: string): Promise<void>;
12
+ static isCmdAvailable(...args: Parameters<typeof isCmdAvailable>): Promise<boolean>;
11
13
  }
@@ -1,4 +1,5 @@
1
1
  import { $ } from "bun";
2
+ import { isCmdAvailable } from "./cmd";
2
3
  import { Colors } from "./colors";
3
4
  import { getEnvVariables } from "./env";
4
5
  import { Log } from "./log";
@@ -25,4 +26,7 @@ export class Utils {
25
26
  console.log(`Successfully updated version in ${fileLocation} to ${version}`);
26
27
  }
27
28
  }
29
+ static async isCmdAvailable(...args) {
30
+ return isCmdAvailable(...args);
31
+ }
28
32
  }
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.19",
6
+ "version": "1.0.21",
7
7
  "repository": {
8
8
  "url": "git+https://github.com/tahminator/pipeline.git"
9
9
  },