Skip to content

Commit

Permalink
Updates/starship js (#464)
Browse files Browse the repository at this point in the history
* README updates

* generateMnemonic

* generateMnemonic (using bip39 only)

* readme
  • Loading branch information
pyramation authored Jun 7, 2024
1 parent c6a9524 commit 502b4fc
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 84 deletions.
28 changes: 6 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,17 @@ Stay tuned for a `create-cosmos-app` boilerplate! For now, this is the most reco

- We recommend studying the [osmojs starship integration](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs/starship) and replicating it.
- Add your configs, similar to how it's done [here](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs/starship/configs)
- Add your workflows for github [like this](https://github.com/osmosis-labs/osmojs/blob/main/.github/workflows/e2e-tests.yaml)
- Add `yarn starship` commands to your package.json scripts [like this](https://github.com/osmosis-labs/osmojs/blob/20d749c8c5a4ec3db374221dabdf185fa18025a3/packages/osmojs/package.json#L34C5-L38C74)
- Add your workflows for GitHub Actions [like this](https://github.com/osmosis-labs/osmojs/blob/main/.github/workflows/e2e-tests.yaml)
- Add `yarn starship` commands to your package.json scripts [like this](https://github.com/osmosis-labs/osmojs/blob/c456184666eda55cd6fee5cd09ba6c05c898d55c/packages/osmojs/package.json#L31-L34)
— Note the jest configurations in the [osmojs package](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs)


This will allow you to run `yarn starship` to `setup`, `deploy`, `clean` and other `starship` commands:
This will allow you to run `yarn starship` to `start`, `setup`, `deploy`, `stop` and other `starship` commands:

#### Deploying `Starship` 🚀

```sh
# setup helm/starship
yarn starship setup

# sanity check
yarn starship get-pods

# deploy starship
yarn starship deploy

# wait til STATUS=Running
yarn starship get-pods

# port forwarding
yarn starship start-ports

# check pids
yarn starship port-pids
yarn starship start
```

#### Running End-to-End Tests 🧪
Expand All @@ -82,8 +66,8 @@ yarn starship:watch
# stop port forwarding (done by clean() too)
# yarn starship stop-ports

# stop ports and delete & remove helm chart
yarn starship clean
# stop ports and delete deployment
yarn starship stop
```

## Related
Expand Down
35 changes: 12 additions & 23 deletions clients/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,17 @@ Stay tuned for a `create-cosmos-app` boilerplate! For now, this is the most reco

- We recommend studying the [osmojs starship integration](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs/starship) and replicating it.
- Add your configs, similar to how it's done [here](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs/starship/configs)
- Add your workflows for github [like this](https://github.com/osmosis-labs/osmojs/blob/main/.github/workflows/e2e-tests.yaml)
- Add `yarn starship` commands to your package.json scripts [like this](https://github.com/osmosis-labs/osmojs/blob/20d749c8c5a4ec3db374221dabdf185fa18025a3/packages/osmojs/package.json#L34C5-L38C74)
- Add your workflows for GitHub Actions [like this](https://github.com/osmosis-labs/osmojs/blob/main/.github/workflows/e2e-tests.yaml)
- Add `yarn starship` commands to your package.json scripts [like this](https://github.com/osmosis-labs/osmojs/blob/c456184666eda55cd6fee5cd09ba6c05c898d55c/packages/osmojs/package.json#L31-L34)
— Note the jest configurations in the [osmojs package](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs)


This will allow you to run `yarn starship` to `setup`, `deploy`, `clean` and other `starship` commands:
This will allow you to run `yarn starship` to `start`, `setup`, `deploy`, `stop` and other `starship` commands:

#### Deploying `Starship` 🚀

```sh
# setup helm/starship
yarn starship setup

# sanity check
yarn starship get-pods

# deploy starship
yarn starship deploy

# wait til STATUS=Running
yarn starship get-pods

# port forwarding
yarn starship start-ports

# check pids
yarn starship port-pids
yarn starship start
```

#### Running End-to-End Tests 🧪
Expand All @@ -112,8 +96,8 @@ yarn starship:watch
# stop port forwarding (done by clean() too)
# yarn starship stop-ports

# stop ports and delete & remove helm chart
yarn starship clean
# stop ports and delete deployment
yarn starship stop
```

## CLI Usage
Expand All @@ -130,6 +114,11 @@ npm install -g @starship-ci/cli

### Run starship

```sh
starship start --config ./config/settings.json
```

### Run starhip (manually)
```sh
starship setup --config ./config/settings.json
starship deploy --config ./config/settings.json
Expand Down Expand Up @@ -168,7 +157,7 @@ const client = new StarshipClient({
helmRepo: 'starship',
helmRepoUrl: 'https://cosmology-tech.github.io/starship/',
helmChart: 'devnet',
helmVersion: 'v0.2.1'
helmVersion: 'v0.2.3'
});
```

Expand Down
67 changes: 50 additions & 17 deletions clients/js/packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,65 @@ Stay tuned for a `create-cosmos-app` boilerplate! For now, this is the most reco

- We recommend studying the [osmojs starship integration](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs/starship) and replicating it.
- Add your configs, similar to how it's done [here](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs/starship/configs)
- Add your workflows for github [like this](https://github.com/osmosis-labs/osmojs/blob/main/.github/workflows/e2e-tests.yaml)
- Add `yarn starship` commands to your package.json scripts [like this](https://github.com/osmosis-labs/osmojs/blob/20d749c8c5a4ec3db374221dabdf185fa18025a3/packages/osmojs/package.json#L34C5-L38C74)
- Add your workflows for GitHub Actions [like this](https://github.com/osmosis-labs/osmojs/blob/main/.github/workflows/e2e-tests.yaml)
- Add `yarn starship` commands to your package.json scripts [like this](https://github.com/osmosis-labs/osmojs/blob/c456184666eda55cd6fee5cd09ba6c05c898d55c/packages/osmojs/package.json#L31-L34)
— Note the jest configurations in the [osmojs package](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs)

## Using with CI/CD

This will allow you to run `yarn starship` to `setup`, `deploy`, `clean` and other `starship` commands:
### Install the packages

#### Deploying `Starship` 🚀
Install `@starship-ci/cli` and `starshipjs`

```sh
# setup helm/starship
yarn starship setup
yarn add @starship-ci/cli starshipjs
```

# sanity check
yarn starship get-pods
Add your configuration files, similar to these:

- [Example `config.yaml`](https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/starship/configs/config.yaml)

- [Example `starship.yaml`](https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/starship/configs/starship.yaml)

- [Example `jest.config.js`](https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/jest.starship.config.js)

# deploy starship
yarn starship deploy

# wait til STATUS=Running
yarn starship get-pods
### Update your `package.json` `scripts`:

```json
"starship": "starship --config ./starship/configs/starship.yaml",
"starship:test": "jest --config ./jest.starship.config.js --verbose --bail",
"starship:watch": "jest --watch --config ./jest.starship.config.js"
```

See an [example here](https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/package.json).

### Start starship 🚀

```sh
yarn starship start
```

# port forwarding
### Manual setup & start

```sh
yarn starship setup
yarn starship deploy
yarn starship start-ports
```

### Stopping starship

# check pids
yarn starship port-pids
```sh
yarn starship stop
```

This will allow you to run `yarn starship` to `start`, `setup`, `deploy`, `stop` and other `starship` commands:

#### Deploying `Starship` 🚀

```sh
yarn starship start
```

#### Running End-to-End Tests 🧪
Expand All @@ -90,8 +122,8 @@ yarn starship:watch
# stop port forwarding (done by clean() too)
# yarn starship stop-ports

# stop ports and delete & remove helm chart
yarn starship clean
# stop ports and delete deployment
yarn starship stop
```

## CLI Usage
Expand Down Expand Up @@ -128,6 +160,7 @@ Here's a concise overview of the commands available in the `starship` CLI:

| Command | Description |
| ---------------- | ----------------------------------------------- |
| `start` | Setup, Deploy, and Start Ports. |
| `setup` | Setup initial configuration and dependencies. |
| `deploy` | Deploy starship using specified options or configuration file. |
| `start-ports` | Start port forwarding for the deployed services. |
Expand Down
51 changes: 31 additions & 20 deletions clients/js/packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,20 @@ Stay tuned for a `create-cosmos-app` boilerplate! For now, this is the most reco

- We recommend studying the [osmojs starship integration](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs/starship) and replicating it.
- Add your configs, similar to how it's done [here](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs/starship/configs)
- Add your workflows for github [like this](https://github.com/osmosis-labs/osmojs/blob/main/.github/workflows/e2e-tests.yaml)
- Add `yarn starship` commands to your package.json scripts [like this](https://github.com/osmosis-labs/osmojs/blob/20d749c8c5a4ec3db374221dabdf185fa18025a3/packages/osmojs/package.json#L34C5-L38C74)
- Add your workflows for GitHub Actions [like this](https://github.com/osmosis-labs/osmojs/blob/main/.github/workflows/e2e-tests.yaml)
- Add `yarn starship` commands to your package.json scripts [like this](https://github.com/osmosis-labs/osmojs/blob/c456184666eda55cd6fee5cd09ba6c05c898d55c/packages/osmojs/package.json#L31-L34)
— Note the jest configurations in the [osmojs package](https://github.com/osmosis-labs/osmojs/tree/main/packages/osmojs)


This will allow you to run `yarn starship` to `setup`, `deploy`, `clean` and other `starship` commands:
This will allow you to run `yarn starship` to `start`, `setup`, `deploy`, `stop` and other `starship` commands:

#### Deploying `Starship` 🚀

```sh
# setup helm/starship
yarn starship setup
yarn starship start

# sanity check
yarn starship get-pods

# deploy starship
yarn starship deploy

# wait til STATUS=Running
yarn starship get-pods

# port forwarding
yarn starship start-ports

# check pids
yarn starship port-pids
```

#### Running End-to-End Tests 🧪
Expand All @@ -99,12 +86,36 @@ yarn starship:watch
# stop port forwarding (done by clean() too)
# yarn starship stop-ports

# stop ports and delete & remove helm chart
yarn starship clean
# stop ports and delete deployment
yarn starship stop
```

## Advanced Usage

### Manual setup

Instead of using `yarn starship start`, you can also to each step, and do checks in between:

```sh
# setup helm/starship
yarn starship setup

# sanity check
yarn starship get-pods

# deploy starship
yarn starship deploy

# wait til STATUS=Running
yarn starship get-pods

# port forwarding
yarn starship start-ports

# check pids
yarn starship port-pids
```

The `StarshipClient` simplifies managing Kubernetes resources, specifically tailored for developers working in interchain environments. Below is an example showing how to instantiate the client and use it to manage a Helm deployment:

### Initializing the Client
Expand All @@ -120,7 +131,7 @@ const client = new StarshipClient({
helmRepo: 'starship',
helmRepoUrl: 'https://cosmology-tech.github.io/starship/',
helmChart: 'devnet',
helmVersion: 'v0.2.1'
helmVersion: 'v0.2.3'
});
```

Expand Down
41 changes: 40 additions & 1 deletion clients/js/packages/starshipjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,53 @@ npm install starshipjs

NOTE: Before you code! You'll want to use the CLI tool ([`@starship-ci/cli`](https://github.com/cosmology-tech/starship/tree/main/clients/js/packages/cli)) in a package.json to get starship working.

Once you add `@starship-ci/cli` to your project, you can spint up `starship` as easy as 1-2-3:
### Install the packages

Install `@starship-ci/cli` and `starshipjs`

```sh
yarn add @starship-ci/cli starshipjs
```

Add your configuration files, similar to these:

- [Example `config.yaml`](https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/starship/configs/config.yaml)

- [Example `starship.yaml`](https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/starship/configs/starship.yaml)

- [Example `jest.config.js`](https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/jest.starship.config.js)


### Update your `package.json` `scripts`:

```json
"starship": "starship --config ./starship/configs/starship.yaml",
"starship:test": "jest --config ./jest.starship.config.js --verbose --bail",
"starship:watch": "jest --watch --config ./jest.starship.config.js"
```

See an [example here](https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/package.json).

### Start starship 🚀

```sh
yarn starship start
```

### Manual setup & start

```sh
yarn starship setup
yarn starship deploy
yarn starship start-ports
```

### Stopping starship

```sh
yarn starship stop
```

## Using the Client

StarshipJS is a utility library that provides helpers to leverage [Starship](https://github.com/cosmology-tech/starship)'s internal chain registry, emulating the style of code used in projects like [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit).
Expand Down
1 change: 1 addition & 0 deletions clients/js/packages/starshipjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"dependencies": {
"@chain-registry/client": "1.18.1",
"bip39": "^3.1.0",
"js-yaml": "^4.1.0",
"node-fetch": "^2.6.9"
},
Expand Down
3 changes: 2 additions & 1 deletion clients/js/packages/starshipjs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './config';
export * from './hooks';
export * from './hooks';
export * from './utils';
3 changes: 3 additions & 0 deletions clients/js/packages/starshipjs/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { generateMnemonic } from 'bip39'

export { generateMnemonic };
Loading

0 comments on commit 502b4fc

Please sign in to comment.