Skip to content

Commit

Permalink
Merge pull request #8 from ciegovolador/package-migration
Browse files Browse the repository at this point in the history
chore(structure): change package build to copy from nostr
  • Loading branch information
grunch authored Nov 13, 2024
2 parents e4f293b + 1df9c0f commit 7425bff
Show file tree
Hide file tree
Showing 97 changed files with 5,119 additions and 25,523 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository

github: [MostroP2P]
custom: ["https://geyser.fund/project/mostro"]
custom: ['https://geyser.fund/project/mostro']
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "\U0001F41E Bug report"
description: Create a report to help us improve
title: "[Bug]: "
labels: ["bug"]
title: '[Bug]: '
labels: ['bug']
assignees:
- sonofmagic
body:
Expand Down Expand Up @@ -31,7 +31,7 @@ body:
The reproduction should be **minimal** - i.e. it should contain only the bare minimum amount of code needed
to show the bug.
Please do not just fill in a random link. The issue will be closed if no valid reproduction is provided.
placeholder: Reproduction Link
validations:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ contact_links:
# about: Love Vue.js? Please consider supporting us via Patreon.
# - name: Open Collective
# url: https://opencollective.com/vuejs/donate
# about: Love Vue.js? Please consider supporting us via Open Collective.
# about: Love Vue.js? Please consider supporting us via Open Collective.
17 changes: 9 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@ jobs:
with:
fetch-depth: 0
# run before Set node , otherwise show Unable to locate executable file: pnpm error
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Use just
- uses: extractions/setup-just@v2

- name: Use bun
- uses: oven-sh/setup-bun@v2

- name: Set node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
cache: npm
registry-url: 'https://registry.npmjs.org'

- name: Install Dependencies
run: pnpm i
run: just install

- name: Build
run: pnpm run build
run: just build
- name: Test
run: pnpm run test
run: just test
- uses: codecov/codecov-action@v4
- name: Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: extractions/setup-just@v2
- uses: oven-sh/setup-bun@v2
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
cache: 'npm'

- run: pnpm i
- run: pnpm build
- run: pnpm test
- run: just install
- run: just build
- run: just test

- uses: codecov/codecov-action@v4
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pnpm dlx commitlint --edit $1
bunx --no -- commitlint --edit $1
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pnpm lint-staged
just test
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"trailingComma": "es5"
}
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ If you're looking for somewhere to start contributing, check out the [good first
## Pull Request Guidelines

Each pull request should focus on a single change. For example:

- ✅ Add new feature to orders handling
- ✅ Fix bug in message encryption
- ❌ Add new feature AND refactor message handling (should be two PRs)
Expand Down Expand Up @@ -96,6 +97,7 @@ npm run format
```

### Types

- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
Expand All @@ -116,16 +118,19 @@ We follow a review process similar to Bitcoin Core:
## Setting Up Development Environment

1. Clone your fork:

```bash
git clone https://github.com/your-username/mostro-tools.git
```

2. Install dependencies:

```bash
npm install
```

3. Create a branch for your changes:

```bash
git checkout -b feat/my-feature
```
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

Tools for developing Mostro clients.

This package is only providing lower-level functionality.
This package is only providing lower-level functionality.


## Roadmap
## Roadmap

### Mostro Core Implementation

Expand All @@ -20,7 +19,6 @@ Implementation of core functionality in TypeScript/JavaScript. See [mostro-core]
- `rating.ts` - User rating implementation
- `user.ts` - User management functionality


### Client Implementation

Implementation of core functionality in TypeScript/JavaScript. See [mostro-core](https://github.com/MostroP2P/mostro-cli).
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Use this section to tell people about which versions of your project are
currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
| Version | Supported |
| ------- | --------- |

## Reporting a Vulnerability

Expand Down
63 changes: 63 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const fs = require('node:fs');
const esbuild = require('esbuild');
const { join } = require('path');

const entryPoints = fs.readdirSync(process.cwd()).filter(
(file) =>
file.endsWith('.ts') &&
// file !== 'core.ts' &&
// file !== 'test-helpers.ts' &&
// file !== 'helpers.ts' &&
// file !== 'benchmarks.ts' &&
!file.endsWith('.config.d.ts') &&
!file.endsWith('.config.ts') &&
!file.endsWith('.test.ts') &&
fs.statSync(join(process.cwd(), file)).isFile()
);

let common = {
entryPoints,
bundle: true,
sourcemap: 'external',
};

esbuild
.build({
...common,
outdir: 'lib/esm',
format: 'esm',
packages: 'external',
tsconfig: './tsconfig.json',
})
.then(() => console.log('esm build success.'));

esbuild
.build({
...common,
outdir: 'lib/cjs',
format: 'cjs',
packages: 'external',
tsconfig: './tsconfig.json',
})
.then(() => {
const packageJson = JSON.stringify({ type: 'commonjs' });
fs.writeFileSync(`${__dirname}/lib/cjs/package.json`, packageJson, 'utf8');

console.log('cjs build success.');
});

esbuild
.build({
...common,
entryPoints: ['index.ts'],
outfile: 'lib/mostro.bundle.js',
format: 'iife',
globalName: 'MostroTools',
define: {
window: 'self',
global: 'self',
process: '{"env": {}}',
},
tsconfig: './tsconfig.json',
})
.then(() => console.log('standalone build success.'));
Binary file added bun.lockb
Binary file not shown.
10 changes: 10 additions & 0 deletions client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { test, expect } from 'bun:test';
import { client } from './mostro.ts';

test('Client', () => {
const testValue = 'Mostro';
const result = client.hello(testValue);
const expected = `Hello Mostro! I am a cli :)`;

expect(result).toEqual(expected);
});
113 changes: 113 additions & 0 deletions client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
export function hello(name: string): string {
return `Hello ${name}! I am a cli :)`;
}

export function dispute(name: string): string {
return `Hello ${name}! I am the core :)`;
}

export function neworder(name: string): string {
return `Hello ${name}! I am the core :)`;
}

export function takesell(name: string): string {
return `Hello ${name}! I am the core :)`;
}

export function takebuy(name: string): string {
return `Hello ${name}! I am the core :)`;
}

export function addinvoice(name: string): string {
return `Hello ${name}! I am the core :)`;
}

export function getdm(name: string): string {
return `Hello ${name}! I am the core :)`;
}

export function fiatsent(name: string): string {
return `Hello ${name}! I am the core :)`;
}
export function release(name: string): string {
return `Hello ${name}! I am the core :)`;
}
export function cancel(name: string): string {
return `Hello ${name}! I am the core :)`;
}
export function rate(name: string): string {
return `Hello ${name}! I am the core :)`;
}
export function admcancel(name: string): string {
return `Hello ${name}! I am the core :)`;
}
export function admsettle(name: string): string {
return `Hello ${name}! I am the core :)`;
}
export function admlistdisputes(name: string): string {
return `Hello ${name}! I am the core :)`;
}
export function admaddsolver(name: string): string {
return `Hello ${name}! I am the core :)`;
}
export function admtakedispute(name: string): string {
return `Hello ${name}! I am the core :)`;
}

export function help(command: string): string {
let result = '';
const commandList = `listorders, neworder, takesell, takebuy , addinvoice, getdm, fiatsent, release, cancel, rate, dispute, admcancel, admsettle, admlistdisputes, admaddsolver, admtakedispute`;
switch (command) {
case 'listorders':
result = `Requests open orders from Mostro pubkey`;
break;
case 'neworder':
result = `Create a new buy/sell order on Mostro`;
break;
case 'takesell':
result = `Take a sell order from a Mostro pubkey`;
break;
case 'takebuy':
result = `Take a buy order from a Mostro pubkey`;
break;
case 'addinvoice':
result = `Buyer add a new invoice to receive the payment`;
break;
case 'getdm':
result = `Get the latest direct messages from Mostro`;
break;
case 'fiatsent':
result = `Send fiat sent message to confirm payment to other user`;
break;
case 'release':
result = `Settle the hold invoice and pay to buyer`;
break;
case 'cancel':
result = `Cancel a pending order`;
break;
case 'rate':
result = `Rate counterpart after a successful trade`;
break;
case 'dispute':
result = `Start a dispute`;
break;
case 'admcancel':
result = `Cancel an order (only admin)`;
break;
case 'admsettle':
result = `Settle a seller's hold invoice (only admin)`;
break;
case 'admlistdisputes':
result = `Requests open disputes from Mostro pubkey`;
break;
case 'admaddsolver':
result = `Add a new dispute's solver (only admin)`;
break;
case 'admtakedispute':
result = `Admin or solver take a Pending dispute (only admin)`;
break;
default:
result = `we don't have that command; Choosea supported one (${commandList})`;
}
return result;
}
3 changes: 3 additions & 0 deletions coderabbit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
path_filters:
exclude:
- 'lib/**'
4 changes: 2 additions & 2 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { UserConfig } from '@commitlint/types'
import type { UserConfig } from '@commitlint/types';
// import { RuleConfigSeverity } from '@commitlint/types'

export default <UserConfig>{
extends: ['@commitlint/config-conventional'],
}
};
10 changes: 10 additions & 0 deletions core.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { test, expect } from 'bun:test';
import { core } from './mostro.ts';

test('Core', () => {
const testValue = 'Mostro';
const result = core.hello(testValue);
const expected = `Hello Mostro! I am the core :)`;

expect(result).toEqual(expected);
});
Loading

0 comments on commit 7425bff

Please sign in to comment.