bitrise-api-cli 0.0.3 → 0.0.4
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/README.md +9 -8
- package/dist/bin.js +36 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npx bitrise-api-cli@latest download --token <BITRISE_TOKEN> --workflow <WORKFLOW
|
|
|
23
23
|
npx bitrise-api-cli@latest download \
|
|
24
24
|
--token <BITRISE_TOKEN> \
|
|
25
25
|
--workflow <WORKFLOW_NAME> \
|
|
26
|
-
--
|
|
26
|
+
--slug <APP_SLUG>
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## 🔐 Configuration
|
|
@@ -40,11 +40,12 @@ npx bitrise-api-cli@latest download \
|
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
Options:
|
|
43
|
-
-t, --token <TOKEN>
|
|
44
|
-
-w, --workflow <
|
|
45
|
-
-s, --
|
|
46
|
-
-
|
|
47
|
-
-
|
|
43
|
+
-t, --token <TOKEN> bitrise api token (or $BITRISE_API_CLI_TOKEN)
|
|
44
|
+
-w, --workflow <WORKFLOW_NAME> workflow to get apk from (or $BITRISE_API_CLI_WORKFLOW)
|
|
45
|
+
-s, --slug <APP_SLUG> bitrise app slug (or $BITRISE_APP_SLUG) see bitrise project url to get slug
|
|
46
|
+
-a, --artifact <ARTIFACT_TYPE> bitrise artifact type "ios-ipa" or "android-apk"
|
|
47
|
+
-d, --debug output extra debugging (default: false)
|
|
48
|
+
-h, --help display help for command
|
|
48
49
|
```
|
|
49
50
|
|
|
50
51
|
## 💡 Examples
|
|
@@ -56,7 +57,7 @@ Options:
|
|
|
56
57
|
npx bitrise-api-cli@latest download \
|
|
57
58
|
--token abc123 \
|
|
58
59
|
--workflow android-release \
|
|
59
|
-
--
|
|
60
|
+
--slug a1b2c3d4e5f6
|
|
60
61
|
|
|
61
62
|
# Enable debug logging
|
|
62
63
|
npx bitrise-api-cli@latest download --debug \
|
|
@@ -100,7 +101,7 @@ Download the latest artifacts to test without building:
|
|
|
100
101
|
npx bitrise-api-cli@latest download \
|
|
101
102
|
--token $BITRISE_API_TOKEN \
|
|
102
103
|
--workflow android-release \
|
|
103
|
-
--
|
|
104
|
+
--slug $BITRISE_APP_SLUG
|
|
104
105
|
```
|
|
105
106
|
|
|
106
107
|
## 📝 License
|
package/dist/bin.js
CHANGED
|
@@ -3,16 +3,21 @@
|
|
|
3
3
|
// src/bin.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
|
|
6
|
+
// src/cliOptions.types.ts
|
|
7
|
+
var validArtifactTypes = ["android-apk", "ios-ipa"];
|
|
8
|
+
|
|
6
9
|
// src/bitrise/env.ts
|
|
7
10
|
var ENV = {
|
|
8
11
|
appSlug: "",
|
|
9
12
|
token: "",
|
|
10
|
-
workflow: ""
|
|
13
|
+
workflow: "",
|
|
14
|
+
artifactType: "android-apk"
|
|
11
15
|
};
|
|
12
16
|
var saveOptions = (options) => {
|
|
13
|
-
ENV.appSlug = options
|
|
14
|
-
ENV.token = options
|
|
15
|
-
ENV.workflow = options
|
|
17
|
+
ENV.appSlug = options.slug;
|
|
18
|
+
ENV.token = options.token;
|
|
19
|
+
ENV.workflow = options.workflow;
|
|
20
|
+
ENV.artifactType = options.artifact;
|
|
16
21
|
};
|
|
17
22
|
var isEnvValid = () => {
|
|
18
23
|
if (ENV.appSlug.length < 1) {
|
|
@@ -27,6 +32,10 @@ var isEnvValid = () => {
|
|
|
27
32
|
console.log("No workflow provided! (see --help for more information)");
|
|
28
33
|
return false;
|
|
29
34
|
}
|
|
35
|
+
if (!validArtifactTypes.includes(ENV.artifactType)) {
|
|
36
|
+
console.log(`Invalid artifact type "${ENV.artifactType}"! (see --help for more information)`);
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
30
39
|
return true;
|
|
31
40
|
};
|
|
32
41
|
|
|
@@ -1454,13 +1463,20 @@ var fetchArtifactList = async (buildSlug) => {
|
|
|
1454
1463
|
if (!data) throw new Error("buildArtifact().artifactList returned no data");
|
|
1455
1464
|
return data;
|
|
1456
1465
|
};
|
|
1466
|
+
var fetchArtifactByType = async (buildSlug) => {
|
|
1467
|
+
const artifactInfo = await fetchArtifactList(buildSlug);
|
|
1468
|
+
const artifactMetadata = artifactInfo.find((artifact) => artifact.artifactType === ENV.artifactType);
|
|
1469
|
+
if (!artifactMetadata || !artifactMetadata.slug)
|
|
1470
|
+
throw new Error(`Found no ${ENV.artifactType} in build Slug: ${buildSlug}`);
|
|
1471
|
+
return artifactMetadata;
|
|
1472
|
+
};
|
|
1457
1473
|
|
|
1458
1474
|
// src/helper/debugLog.ts
|
|
1459
1475
|
var debugLog = (label, data) => console.log(`${label}: ${JSON.stringify(data, void 0, 2)}`);
|
|
1460
1476
|
|
|
1461
1477
|
// src/bitrise/fetchBuilds.ts
|
|
1462
1478
|
var getAllBuilds = async () => {
|
|
1463
|
-
const { data } = await api.builds().buildList({ appSlug: ENV.appSlug });
|
|
1479
|
+
const { data } = await api.builds().buildList({ appSlug: ENV.appSlug, status: 1 });
|
|
1464
1480
|
if (!data) throw Error("no build data");
|
|
1465
1481
|
return data;
|
|
1466
1482
|
};
|
|
@@ -1492,7 +1508,6 @@ var downloadFile = async (fileUrl, outputLocationPath) => {
|
|
|
1492
1508
|
};
|
|
1493
1509
|
|
|
1494
1510
|
// src/downloadLatestArtifacts.ts
|
|
1495
|
-
var targetArtifactType = "android-apk";
|
|
1496
1511
|
var downloadLatestArtifacts = async (options) => {
|
|
1497
1512
|
saveOptions(options);
|
|
1498
1513
|
if (!isEnvValid()) return process.exit(1);
|
|
@@ -1504,11 +1519,12 @@ var downloadLatestArtifacts = async (options) => {
|
|
|
1504
1519
|
console.log("Latest build contained no Slug");
|
|
1505
1520
|
return process.exit(1);
|
|
1506
1521
|
}
|
|
1507
|
-
const
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1522
|
+
const artifactMetadata = await oraPromise(fetchArtifactByType(latestBuild.slug), {
|
|
1523
|
+
text: "fetching artifact list",
|
|
1524
|
+
failText: (error) => `fetching artifact list failed with error: ${error}`
|
|
1525
|
+
});
|
|
1511
1526
|
if (options.debug) debugLog("artifactMetadata", artifactMetadata);
|
|
1527
|
+
if (!artifactMetadata || !artifactMetadata.slug) return process.exit(1);
|
|
1512
1528
|
const artifact = await oraPromise(
|
|
1513
1529
|
fetchArtifact({
|
|
1514
1530
|
artifactSlug: artifactMetadata.slug,
|
|
@@ -1529,6 +1545,14 @@ var downloadLatestArtifacts = async (options) => {
|
|
|
1529
1545
|
|
|
1530
1546
|
// src/bin.ts
|
|
1531
1547
|
var program = new Command();
|
|
1532
|
-
program.version("0.0.
|
|
1533
|
-
program.command("download").option("-t, --token <TOKEN>", "bitrise api token (or $BITRISE_API_CLI_TOKEN)"
|
|
1548
|
+
program.version("0.0.4");
|
|
1549
|
+
program.command("download").option("-t, --token <TOKEN>", "bitrise api token (or $BITRISE_API_CLI_TOKEN)", process.env.BITRISE_API_CLI_TOKEN).option(
|
|
1550
|
+
"-w, --workflow <WORKFLOW_NAME>",
|
|
1551
|
+
"workflow to get apk from (or $BITRISE_API_CLI_WORKFLOW)",
|
|
1552
|
+
process.env.BITRISE_API_CLI_WORKFLOW
|
|
1553
|
+
).option(
|
|
1554
|
+
"-s, --slug <APP_SLUG>",
|
|
1555
|
+
"bitrise app slug (or $BITRISE_APP_SLUG) see bitrise project url to get slug",
|
|
1556
|
+
process.env.BITRISE_APP_SLUG
|
|
1557
|
+
).option("-a, --artifact <ARTIFACT_TYPE>", 'bitrise artifact type "ios-ipa" or "android-apk"', "android-apk").option("-d, --debug", "output extra debugging", false).description("Download bitrise artifacts").action((options) => downloadLatestArtifacts(options).catch(() => process.exit(1)));
|
|
1534
1558
|
program.parse(process.argv);
|