A small NPM library that helps you search and fetch Bitrise Workflow steps.
You'll need an Algolia App ID and an API key with search and browse persmission.
import StepLib from '@bitrise/steplib-search';
const stepLib = new StepLib(
'ALGOLIA_APP_ID',
'ALGOLIA_API_KEY',
// You can optionally pass a config object for the indices
// These are the defaults
{ stepIndex: 'steplib_steps', inputsIndex: 'steplib_inputs' }
);
Wihtout any options, we get the all steps (and all versions) with minimal information
const latestSteps: Step[] = await stepLib.list();
Result
// latestSteps
[
...
{ "cvs": "[email protected]" },
{ "cvs": "[email protected]" },
{ "cvs": "[email protected]" },
{ "cvs": "[email protected]" },
{ "cvs": "[email protected]" },
{ "cvs": "[email protected]" },
{ "cvs": "[email protected]" },
...
]
Search for a specific step, with all versions and inputs included
const allFlutterSteps: Step[] = await stepLib.list({
query: 'flutter',
latestOnly: false,
includeInputs: true
});
Result
// allFlutterSteps
[
...
{
"cvs": "[email protected]",
"inputs": [
{ "cvs": "[email protected]", "order": 0 },
{ "cvs": "[email protected]", "order": 1 },
{ "cvs": "[email protected]", "order": 2 }
...
]
},
{
"cvs": "[email protected]",
"inputs": [
{ "cvs": "[email protected]", "order": 0 },
{ "cvs": "[email protected]", "order": 1 },
{ "cvs": "[email protected]", "order": 2 }
]
},
{
"cvs": "[email protected]",
"inputs": [
{ "cvs": "[email protected]", "order": 0 },
{ "cvs": "[email protected]", "order": 1 }
]
},
{
"cvs": "[email protected]",
"inputs": [
{ "cvs": "[email protected]", "order": 0 }
]
},
{
"cvs": "[email protected]",
"inputs": [
{ "cvs": "[email protected]", "order": 0 }
]
}
...
]
List steps by id, you can include a version to get an exact version, or omit it to get the latest
const workflowSteps: Step[] = await stepLib.list({
stepIds: ['script', '[email protected]', '[email protected]'],
algoliaOptions: {
attributesToRetrieve: ['id', 'version', 'cvs', 'is_latest']
}
});
Result
// workflowSteps
[
{
"cvs": "[email protected]",
"id": "script",
"version": "1.1.6",
"is_latest": true
},
{
"cvs": "[email protected]",
"id": "android-build",
"version": "0.10.0",
"is_latest": true
},
{
"cvs": "[email protected]",
"id": "github-release",
"version": "0.9.3",
"is_latest": false
}
]
You can use projectTypes
to speecify which platfrom you are looking for
const iosAndAndroidLatestSteps: Step[] = await stepLib.list({
latestOnly: true,
projectTypes: ['ios', 'android'],
algoliaOptions: {
attributesToRetrieve: ['cvs', 'step.project_type_tags']
}
});
Result
// iosAndAndroidLatestSteps
[
...
{
"cvs": "[email protected]",
"step": {
"project_type_tags": [
"android"
]
}
},
{
"cvs": "[email protected]",
"step": {
"project_type_tags": [
"ios",
"xamarin",
"react-native"
]
}
},
{
"cvs": "[email protected]",
"step": {
"project_type_tags": [
"ios",
"xamarin"
]
}
},
{
"cvs": "[email protected]",
"step": {
"project_type_tags": [
"android",
"react-native",
"flutter"
]
}
},
{
"cvs": "[email protected]",
"step": {
"project_type_tags": [
"android"
],
}
},
...
]
With custom algoliaOptions
, you can override any Algolia parameter
const customAlgoliaOptions: Step[] = await stepLib.list({
query: 'react-native',
latestOnly: false,
algoliaOptions: {
attributesToRetrieve: ['id', 'version', 'cvs', 'info']
}
});
Result
// customAlgoliaOptions
[
{
"cvs": "[email protected]",
"id": "react-native-bundle",
"version": "1.0.4",
"info": {
"asset_urls": {
"icon.svg": "https://bitrise-steplib-collection.s3.amazonaws.com/steps/react-native-bundle/assets/icon.svg"
}
}
},
{
"cvs": "[email protected]",
"id": "install-react-native",
"version": "0.9.2",
"info": {
"asset_urls": {
"icon.svg": "https://bitrise-steplib-collection.s3.amazonaws.com/steps/install-react-native/assets/icon.svg"
}
}
},
{
"cvs": "[email protected]",
"id": "appcenter-codepush-release-react-native",
"version": "0.0.2",
"info": {
"asset_urls": {
"icon.svg": "https://bitrise-steplib-collection.s3.amazonaws.com/steps/appcenter-codepush-release-react-native/assets/icon.svg"
}
}
}
]
You can leverage Algolia's fuzzy search
const fuzzySteps: Step[] = await stepLib.list({
query: 'Anbroid Ebulator',
latestOnly: true,
algoliaOptions: {
restrictSearchableAttributes: ['step.title'],
typoTolerance: true,
attributesToRetrieve: ['step.title', 'cvs']
}
});
Result
// fuzzySteps
[
{
"cvs": "[email protected]",
"step": {
"title": "Start Android emulator"
}
},
{
"cvs": "[email protected]",
"step": {
"title": "Create Android emulator"
}
},
{
"cvs": "[email protected]",
"step": {
"title": "Wait for Android emulator"
}
}
]
Include these scripts
<script src="//unpkg.com/algoliasearch/dist/algoliasearch.min.js"></script>
<script src="//unpkg.com/@bitrise/steplib-search"></script>
Then use it similarly as descibed above
var stepLib = new StepLib('ALGOLIA_APP_ID', 'ALGOLIA_API_KEY');
stepLib.list().then(function(latestSteps) {
console.log('Yay, steps!', latestSteps);
});
- Install dependecies:
yarn
- Run tests:
yarn test
oryarn test --watch
This repo uses a strict commit message structure that follows the Conventional Commits spec. This is used to automate publishing the package to NPM and generating the changelog with Semantic Release.
Using Semantic Release to NPM