Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat: a bunch of user friendliness changes (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Dan <[email protected]>
  • Loading branch information
wyhaines and sebastiendan authored Aug 29, 2023
1 parent fd9a18c commit dc3f147
Show file tree
Hide file tree
Showing 16 changed files with 773 additions and 277 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/npm-package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Publish Package to NPM Registry

on:
release:
types: [published]

jobs:
npm-package:
runs-on: ubuntu-latest-16-core
Expand All @@ -17,3 +19,18 @@ jobs:
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

notification:
runs-on: ubuntu-latest-16-core
needs: npm-package
steps:
- name: Send Slack notification
uses: slackapi/[email protected]
with:
payload: |
{
"repository": "${{ github.repository }}",
"version": "${{ github.ref }}"
}
env:
SLACK_WEBHOOK_URL: ${{ vars.RELEASE_PIPELINE_SLACK_WEBHOOK_URL }}
20 changes: 0 additions & 20 deletions .github/workflows/release-pipeline.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/test:smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Smoke test

on:
pull_request:
branches:
- main

jobs:
smoke-test:
runs-on: ubuntu-latest-16-core
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up NodeJS
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install deps
run: npm ci

- name: Build
run: npm run build

- name: Smoke root command
run: node dist/main --help

- name: Smoke start command
run: (node dist/main start -v | tee >(grep -q "🔥 Everything is done! 🔥" && pkill -P $$); [ $? -eq 143 ])

- name: Smoke clean command
run: node dist/main clean -v

- name: Upload logs
uses: actions/upload-artifact@v3
if: always()
with:
name: logs
path: /home/runner/.local/state/topos-playground/logs
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<img src="./.github/assets/topos_logo_dark.png#gh-dark-mode-only" alt="Logo" width="200">
<br />
<p align="center">
<b>Topos Playground</b> is the CLI to run a local devnet to test the Topos ecosystem 🚀
<b>Topos Playground</b> is a CLI make it simple to run a local Topos devnet 🚀
</p>
<br />
</div>
Expand All @@ -26,10 +26,29 @@ $ npm install -g @topos-protocol/topos-playground

### Run the CLI

If you installed the package manually, you can run it like so
If you have installed the package manually, you can run it like so:

```
$ topos-playground [start|clean]
$ topos-playground --help
```

The playground respects XDG Base Directory Specifications, so by default, it will store
data used while running in `$HOME/.local/share/topos-playground` and it will store logs
in `$HOME/.state/topos-playground/logs`.

To override these default locations, you can set your `HOME`, `XDG_DATA_HOME` and `XDG_STATE_HOME`
environment variables, or specify them in a `.env` file.

```
$ HOME=/tmp topos-playground start
```

By default, topos-playground sends output to both your console and to a log file when it is running.
To disable this, you can use the `--quiet` flag to prevent output from going to the console, or the
`--no-log` flag to prevent output from going to the log file.

```
$ topos-playground start --quiet
```

Otherwise, you can use `npx` to abstract the installation
Expand Down
53 changes: 33 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@topos-protocol/topos-playground",
"version": "0.0.2",
"description": "CLI to run local Topos devnets with subnets, a TCE network, and apps",
"description": "topos-playground is a CLI tool which handles all of the orchestration necessary to run local Topos devnets with subnets, a TCE network, and apps.",
"author": "Sébastien Dan <[email protected]>",
"license": "MIT",
"bin": {
Expand All @@ -18,8 +18,11 @@
"dependencies": {
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"chalk": "^4.1.2",
"dotenv": "^16.3.1",
"ethers": "^5.7.2",
"nest-commander": "^3.7.1",
"semver": "^7.5.4",
"winston": "^3.8.2"
},
"devDependencies": {
Expand Down
7 changes: 6 additions & 1 deletion src/ReactiveSpawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { ChildProcess, spawn } from 'child_process'
import { userInfo } from 'os'
import { Observable } from 'rxjs'

import { log } from './loggers'

export interface Next {
origin: 'stdout' | 'stderr'
output: string | ChildProcess
Expand All @@ -12,6 +14,9 @@ export class ReactiveSpawn {

reactify(command: string, options?: { runInBackground }) {
return new Observable<Next>((subscriber) => {
if (globalThis.verbose) {
log(`🏃 Running command: ${command}`)
}
const childProcess = spawn(command, { ...options, shell: this._shell })

if (options && options.runInBackground) {
Expand All @@ -22,7 +27,7 @@ export class ReactiveSpawn {
const output = data.toString()
subscriber.next({ origin: 'stdout', output })
})

childProcess.stderr.on('data', (data: Buffer) => {
const output = data.toString()
subscriber.next({ origin: 'stderr', output })
Expand Down
5 changes: 4 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { Module } from '@nestjs/common'

import { CleanCommand } from './commands/clean.command'
import { StartCommand } from './commands/start.command'
import { VersionCommand } from './commands/version.command'
import { Root } from './commands/root.command'

import { ReactiveSpawn } from './ReactiveSpawn'

@Module({
providers: [ReactiveSpawn, CleanCommand, StartCommand],
providers: [ReactiveSpawn, CleanCommand, StartCommand, VersionCommand, Root],
})
export class AppModule {}
Loading

0 comments on commit dc3f147

Please sign in to comment.