|
1 | | -Source code for the @browserstack/wdio-browserstack-service npm module |
| 1 | +# @browserstack/wdio-browserstack-service |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +Core SDK for BrowserStack integration used by the WebdriverIO BrowserStack Service. |
| 7 | +For user configuration and service options, see the official service README: |
| 8 | +[https://github.com/webdriverio/webdriverio/blob/main/packages/wdio-browserstack-service/README.md](https://github.com/webdriverio/webdriverio/blob/main/packages/wdio-browserstack-service/README.md) |
| 9 | + |
| 10 | +## Table of Contents |
| 11 | +1. [Overview](#overview) |
| 12 | +2. [Code Generation](#code-generation) |
| 13 | +3. [Development](#development) |
| 14 | +4. [Contributing](#contributing) |
| 15 | +5. [License](#license) |
| 16 | + |
| 17 | +## Overview |
| 18 | +This package provides the TypeScript-based gRPC client and Protobuf definitions |
| 19 | +used internally by the `@wdio/browserstack-service` plugin for WebdriverIO. |
| 20 | +It includes: |
| 21 | +- Generated TypeScript types and clients from Protobuf definitions. |
| 22 | +- Message factory constructors for backward compatibility. |
| 23 | + |
| 24 | +## Installation |
| 25 | +This module is included as a dependency of the `@wdio/browserstack-service` package. |
| 26 | +Users should install and configure the service as documented in the linked README above. |
| 27 | + |
| 28 | +## Setup & Configuration |
| 29 | +Add the service to your WebdriverIO configuration (`wdio.conf.js`): |
| 30 | +<!-- Usage is provided by @wdio/browserstack-service. --> |
| 31 | +export BROWSERSTACK_USERNAME=your_username |
| 32 | +export BROWSERSTACK_ACCESS_KEY=your_access_key |
| 33 | +``` |
| 34 | +
|
| 35 | +## Usage |
| 36 | +Import and use the gRPC client and message constructors: |
| 37 | +```ts |
| 38 | +import { SDKClient, StartBinSessionRequestConstructor } from '@browserstack/wdio-browserstack-service'; |
| 39 | +
|
| 40 | +// Initialize the client (uses default insecure credentials unless overridden) |
| 41 | +const client = new SDKClient('grpc.browserstack.com:443'); |
| 42 | +
|
| 43 | +// Start a session |
| 44 | +const startReq = StartBinSessionRequestConstructor.create({ |
| 45 | + sdkLanguage: 'typescript', |
| 46 | + sdkVersion: '2.0.0', |
| 47 | + pathProject: process.cwd(), |
| 48 | + cliArgs: process.argv, |
| 49 | +}); |
| 50 | +
|
| 51 | +client.startBinSession(startReq).then(response => { |
| 52 | + console.log('Started session:', response.binSessionId); |
| 53 | +}); |
| 54 | +``` |
| 55 | + |
| 56 | +## Code Generation |
| 57 | +This project uses [Buf](https://docs.buf.build/) and `ts-proto` to |
| 58 | +generate TypeScript code from Protobuf definitions. |
| 59 | + |
| 60 | +### Prerequisites |
| 61 | +- [Buf CLI](https://docs.buf.build/installation) |
| 62 | +- Node.js ≥16 |
| 63 | + |
| 64 | +### Generate & Build |
| 65 | +```bash |
| 66 | +# Clean previously generated files |
| 67 | +npm run clean |
| 68 | + |
| 69 | +# Generate from .proto files |
| 70 | +npm run generate |
| 71 | + |
| 72 | +# Compile to JS and declaration files |
| 73 | +npm run build |
| 74 | +``` |
| 75 | + |
| 76 | +## Code Generation |
| 77 | +This project uses Buf and `ts-proto` to generate TypeScript definitions from Protobuf. |
| 78 | + |
| 79 | +### Prerequisites |
| 80 | +- [Buf CLI](https://docs.buf.build/installation) |
| 81 | +- Node.js ≥16 |
| 82 | + |
| 83 | +### Generate & Build |
| 84 | +```bash |
| 85 | +# Clean generated artifacts |
| 86 | +npm run clean |
| 87 | + |
| 88 | +# Generate TS code from .proto definitions |
| 89 | +npm run generate |
| 90 | + |
| 91 | +# Compile to JavaScript & type declarations |
| 92 | +npm run build |
| 93 | +``` |
| 94 | + |
| 95 | +Generated files appear under `dist/` and should be published to npm. |
| 96 | + |
| 97 | +## Development |
| 98 | +Clone the repository and install dependencies: |
| 99 | +```bash |
| 100 | +git clone https://github.com/browserstack/wdio-browserstack-service.git |
| 101 | +cd wdio-browserstack-service |
| 102 | +npm install |
| 103 | +``` |
| 104 | + |
| 105 | +Run generation and build: |
| 106 | +```bash |
| 107 | +npm run build |
| 108 | +``` |
| 109 | + |
| 110 | +## Contributing |
| 111 | +Contributions are welcome! Please open issues or pull requests in the [GitHub repository](https://github.com/browserstack/wdio-browserstack-service). |
| 112 | + |
| 113 | +## License |
| 114 | +MIT © BrowserStack |
0 commit comments