bitrise-api-cli 0.0.8 → 0.0.9-beta

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.
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  app,
4
4
  buildContext
5
- } from "./chunk-WFYIERBR.js";
5
+ } from "./chunk-5TJLDQ3K.js";
6
6
  import "./chunk-CF25N4TY.js";
7
7
 
8
8
  // src/cli/bin/bash-complete.ts
@@ -5,7 +5,7 @@ import {
5
5
  // src/cli/commands/download/command.ts
6
6
  import { buildCommand } from "@stricli/core";
7
7
  var downloadCommand = buildCommand({
8
- loader: async () => import("./impl-PVD6QYYZ.js"),
8
+ loader: async () => import("./impl-YQ6WYRXO.js"),
9
9
  parameters: {
10
10
  flags: {
11
11
  artifact: {
@@ -42,7 +42,7 @@ var downloadCommand = buildCommand({
42
42
  },
43
43
  install: {
44
44
  kind: "boolean",
45
- brief: "Install the downloaded artifact [android only]",
45
+ brief: "Install the downloaded apk/aab artifact [android only]",
46
46
  default: false
47
47
  }
48
48
  },
@@ -65,7 +65,7 @@ import { buildApplication, buildRouteMap } from "@stricli/core";
65
65
 
66
66
  // package.json
67
67
  var name = "bitrise-api-cli";
68
- var version = "0.0.8";
68
+ var version = "0.0.9-beta";
69
69
  var description = "bitrise api CLI wrapper";
70
70
 
71
71
  // src/cli/app.ts
@@ -85,15 +85,9 @@ var app = buildApplication(root, {
85
85
  });
86
86
 
87
87
  // src/cli/context.ts
88
- import fs from "node:fs";
89
- import os from "node:os";
90
- import path from "node:path";
91
88
  function buildContext(process2) {
92
89
  return {
93
- process: process2,
94
- os,
95
- fs,
96
- path
90
+ process: process2
97
91
  };
98
92
  }
99
93
 
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  app,
4
4
  buildContext
5
- } from "./chunk-WFYIERBR.js";
5
+ } from "./chunk-5TJLDQ3K.js";
6
6
  import "./chunk-CF25N4TY.js";
7
7
 
8
8
  // src/cli/bin/cli.ts
@@ -56,6 +56,59 @@ var installApk = async (apkPath) => {
56
56
  throw new Error("unknown Error");
57
57
  }
58
58
  };
59
+ var installSplitApk = async (apkFolder) => {
60
+ const startTime = Date.now();
61
+ try {
62
+ const { stdout, stderr, code } = await exec(adbPath, ["install-multiple", "-r", "-d", `${apkFolder}/*`], {
63
+ shell: true
64
+ });
65
+ if (code !== 0) throw new Error(`Failed to install split apk error code: ${code}`);
66
+ return { duration: Date.now() - startTime };
67
+ } catch (e) {
68
+ if (e instanceof Error && "stderr" in e) throw new Error(`${e.stderr}`);
69
+ throw new Error("unknown Error");
70
+ }
71
+ };
72
+
73
+ // src/device/install/convertAabToApk.ts
74
+ import fs2 from "node:fs/promises";
75
+ import path2 from "node:path";
76
+
77
+ // src/helper/tempDir.ts
78
+ import fs from "node:fs/promises";
79
+ import { tmpdir } from "node:os";
80
+ import path from "node:path";
81
+ var createTempDir = async (prefix) => {
82
+ const tmpDir = path.join(tmpdir(), `${prefix}-${Date.now()}`);
83
+ await fs.mkdir(tmpDir, { recursive: true });
84
+ return tmpDir;
85
+ };
86
+
87
+ // src/device/install/convertAabToApk.ts
88
+ import { exec as exec2 } from "teen_process";
89
+ var convertAabToApk = async (aabPath) => {
90
+ const startTime = Date.now();
91
+ try {
92
+ const tempDir = await createTempDir("bitrise-api-cli");
93
+ const fileName = path2.basename(aabPath, ".aab");
94
+ const outPath = path2.join(tempDir, `${fileName}.apks`);
95
+ const zipPath = path2.join(tempDir, `${fileName}.zip`);
96
+ const { code } = await exec2("bundletool", [
97
+ "build-apks",
98
+ "--connected-device",
99
+ `--bundle=${fileName}.aab`,
100
+ `--output=${outPath}`
101
+ ]);
102
+ if (code !== 0) throw new Error(`Failed to convert aab to apk: ${code}`);
103
+ await fs2.rename(outPath, zipPath);
104
+ const { code: code2 } = await exec2("unzip", ["-o", zipPath, "-d", tempDir]);
105
+ if (code2 !== 0) throw new Error(`Failed to unzip ${code2}`);
106
+ return { apkFolder: path2.join(tempDir, "./splits"), duration: Date.now() - startTime };
107
+ } catch (e) {
108
+ if (e instanceof Error && "stderr" in e) throw new Error(`${e.stderr}`);
109
+ throw new Error("unknown Error");
110
+ }
111
+ };
59
112
 
60
113
  // src/helper/formatTime.ts
61
114
  var formatTime = (timeMs) => {
@@ -63,10 +116,20 @@ var formatTime = (timeMs) => {
63
116
  return `${(timeMs / 1e3).toFixed(1)}s`;
64
117
  };
65
118
 
119
+ // src/helper/typeHelper.ts
120
+ var isFetchError = (e) => {
121
+ if (typeof e !== "object" || !e) return false;
122
+ return "response" in e && typeof e.response === "object" && !!e.response && "status" in e.response && "statusText" in e.response;
123
+ };
124
+
66
125
  // src/helper/oraHelper.ts
67
126
  var getOraTexts = (label) => ({
68
127
  text: label,
69
- failText: (error) => `${label} failed with error: ${error.message}`,
128
+ failText: (error) => {
129
+ if (isFetchError(error))
130
+ return `${label} failed with HTTP Error ${error.response.status} ${error.response.statusText}`;
131
+ return `${label} failed with error: ${error.message}`;
132
+ },
70
133
  successText: (data) => {
71
134
  if (data && typeof data === "object" && "duration" in data && typeof data.duration === "number") {
72
135
  return `${label} [took ${formatTime(data.duration)}]`;
@@ -78,9 +141,13 @@ var getOraTexts = (label) => ({
78
141
  // src/device/install/run.ts
79
142
  import { oraPromise } from "ora";
80
143
  var installApp = async ({ file, flags }) => {
81
- if (flags.artifact === "android-apk") {
82
- if (!file.endsWith(".apk")) return console.log("Artifact is not an APK file");
144
+ if (flags.artifact === "android-apk" && file.endsWith(".aab")) {
145
+ const { apkFolder } = await oraPromise(convertAabToApk(file), getOraTexts("Convert AAB to Split APK"));
146
+ await oraPromise(installSplitApk(apkFolder), getOraTexts("installing Split APK"));
147
+ } else if (flags.artifact === "android-apk" && file.endsWith(".apk")) {
83
148
  await oraPromise(installApk(file), getOraTexts("installing APK"));
149
+ } else if (flags.artifact === "android-apk") {
150
+ throw Error("Artifact is not an APK or AAB file");
84
151
  } else {
85
152
  return console.log("Installing on iOS is not supported yet");
86
153
  }
@@ -761,6 +828,7 @@ function V0BuildTriggerParamsBuildParamsToJSONTyped(value, ignoreDiscriminator =
761
828
  "environments": value["environments"] == null ? void 0 : value["environments"].map(V0BuildParamsEnvironmentToJSON),
762
829
  "head_repository_url": value["headRepositoryUrl"],
763
830
  "pipeline_id": value["pipelineId"],
831
+ "priority": value["priority"],
764
832
  "pull_request_author": value["pullRequestAuthor"],
765
833
  "pull_request_head_branch": value["pullRequestHeadBranch"],
766
834
  "pull_request_id": value["pullRequestId"],
@@ -1075,6 +1143,12 @@ var BuildsApi = class extends BaseAPI {
1075
1143
  'Required parameter "before" was null or undefined when calling archivedBuildsList().'
1076
1144
  );
1077
1145
  }
1146
+ if (requestParameters["limit"] == null) {
1147
+ throw new RequiredError(
1148
+ "limit",
1149
+ 'Required parameter "limit" was null or undefined when calling archivedBuildsList().'
1150
+ );
1151
+ }
1078
1152
  const queryParameters = {};
1079
1153
  if (requestParameters["after"] != null) {
1080
1154
  queryParameters["after"] = requestParameters["after"];
@@ -1082,6 +1156,9 @@ var BuildsApi = class extends BaseAPI {
1082
1156
  if (requestParameters["before"] != null) {
1083
1157
  queryParameters["before"] = requestParameters["before"];
1084
1158
  }
1159
+ if (requestParameters["limit"] != null) {
1160
+ queryParameters["limit"] = requestParameters["limit"];
1161
+ }
1085
1162
  const headerParameters = {};
1086
1163
  if (this.configuration && this.configuration.apiKey) {
1087
1164
  headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitrise-api-cli",
3
- "version": "0.0.8",
3
+ "version": "0.0.9-beta",
4
4
  "description": "bitrise api CLI wrapper",
5
5
  "module": "index",
6
6
  "type": "module",
@@ -23,17 +23,16 @@
23
23
  "prepublishOnly": "bun i && bun run lint:CI && tsc && bun run build"
24
24
  },
25
25
  "dependencies": {
26
- "@stricli/auto-complete": "1.1.1",
27
26
  "@stricli/core": "1.1.1",
28
27
  "ora": "8.2.0",
29
- "teen_process": "2.2.3"
28
+ "teen_process": "2.3.1"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@biomejs/biome": "1.9.4",
33
- "@openapitools/openapi-generator-cli": "2.16.3",
32
+ "@openapitools/openapi-generator-cli": "2.18.4",
34
33
  "@types/bun": "latest",
35
34
  "@types/teen_process": "^2.0.4",
36
35
  "tsup": "8.4.0",
37
- "typescript": "5.7.3"
36
+ "typescript": "5.8.2"
38
37
  }
39
38
  }