Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit c8c20d2

Browse files
authored
feat(contented): add cli to write, generate, build (#2)
1 parent 7337453 commit c8c20d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+304
-431
lines changed

.eslintrc

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
22
"plugins": ["simple-import-sort"],
33
"extends": ["airbnb-base", "airbnb-typescript/base", "prettier"],
4-
"ignorePatterns": ["**/*.config.ts", "**/*.config.js"],
4+
"ignorePatterns": [
5+
"**/*.config.ts",
6+
"**/*.config.js",
7+
"contented.js",
8+
"**/contented-processor/**/*.d.ts",
9+
"**/contented-processor/**/*.js"
10+
],
511
"rules": {
612
"class-methods-use-this": "off",
713
"import/no-extraneous-dependencies": "off",

.github/dependabot.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "npm"
4-
directory: "/"
3+
- package-ecosystem: 'npm'
4+
directory: '/'
55
schedule:
6-
interval: "daily"
6+
interval: 'daily'
77
labels:
8-
- "kind/dependencies"
9-
versioning-strategy: "increase"
8+
- 'kind/dependencies'
9+
versioning-strategy: 'increase'
1010
commit-message:
1111
include: scope
1212
prefix: bump
1313

14-
- package-ecosystem: "github-actions"
15-
directory: "/"
14+
- package-ecosystem: 'github-actions'
15+
directory: '/'
1616
schedule:
17-
interval: "daily"
17+
interval: 'daily'
1818
labels:
19-
- "kind/dependencies"
19+
- 'kind/dependencies'
2020
commit-message:
2121
include: scope
2222
prefix: bump

.github/governance.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: v1
33
issue:
44
labels:
55
- prefix: triage
6-
list: ["accepted"]
6+
list: ['accepted']
77
multiple: false
88
author_association:
99
collaborator: true
@@ -50,7 +50,7 @@ issue:
5050

5151
- prefix: priority
5252
multiple: false
53-
list: ["urgent-now", "important-soon"]
53+
list: ['urgent-now', 'important-soon']
5454
author_association:
5555
collaborator: true
5656
member: true

.github/labeler.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ labels:
3434
- label: area/workflow
3535
sync: true
3636
matcher:
37-
files: ".github/**"
37+
files: '.github/**'
3838

3939
checks:
40-
- context: "Semantic Pull Request"
40+
- context: 'Semantic Pull Request'
4141
description:
4242
success: Ready for review & merge.
43-
failure: "Missing semantic title or label for merge [kind(directory): title]"
43+
failure: 'Missing semantic title or label for merge [kind(directory): title]'
4444
labels:
4545
any:
4646
- kind/feature

.github/release-drafter.yml

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
name-template: "v$RESOLVED_VERSION"
2-
tag-template: "v$RESOLVED_VERSION"
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
33
categories:
4-
- title: "Features"
4+
- title: 'Features'
55
labels:
6-
- "kind/feature"
7-
- title: "Fixes"
6+
- 'kind/feature'
7+
- title: 'Fixes'
88
labels:
9-
- "kind/fix"
10-
- title: "Chore & Maintenance"
9+
- 'kind/fix'
10+
- title: 'Chore & Maintenance'
1111
labels:
12-
- "kind/refactor"
13-
- "kind/chore"
14-
- "kind/docs"
15-
- title: "Dependencies"
12+
- 'kind/refactor'
13+
- 'kind/chore'
14+
- 'kind/docs'
15+
- title: 'Dependencies'
1616
labels:
17-
- "kind/dependencies"
18-
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
17+
- 'kind/dependencies'
18+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
1919
change-title-escapes: '\<*_&'
2020
version-resolver:
2121
minor:
2222
labels:
23-
- "kind/feature"
23+
- 'kind/feature'
2424
default: patch
2525
prerelease: false
2626
template: |

package-lock.json

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"lint": "eslint --fix . && prettier --write .",
1111
"prepare": "husky install"
1212
},
13+
"dependencies": {
14+
"@birthdayresearch/contented-preview": "0.0.0",
15+
"@birthdayresearch/contented-processor": "0.0.0"
16+
},
1317
"devDependencies": {
1418
"@types/lodash": "^4.14.182",
1519
"@types/node": "16.11.43",
+15-21
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,37 @@
1-
import { defineDocumentType } from "@birthdayresearch/contented-processor";
2-
import { computeContentHeadings } from "@birthdayresearch/contented-processor/fields/headings";
1+
/* eslint-disable */
32
import {
3+
defineDocumentType,
4+
getUnifiedProcessor,
5+
computeContentHeadings,
46
computePath,
57
computeSections,
6-
} from "@birthdayresearch/contented-processor/fields/path";
8+
} from '../contented-processor';
79

810
const Doc = defineDocumentType(() => ({
9-
name: "Doc",
11+
name: 'Doc',
1012
filePathPattern: `docs/**/*.md`,
1113
fields: {
1214
title: {
13-
type: "string",
14-
description: "The title of the documentation.",
15+
type: 'string',
16+
description: 'The title of the documentation.',
1517
required: true,
16-
default: "Contented Documentation",
18+
default: 'Contented Documentation',
1719
},
1820
description: {
19-
type: "string",
21+
type: 'string',
2022
required: false,
2123
},
2224
},
2325
computedFields: {
24-
path: computePath("/", /\d+:/g, ""),
25-
sections: computeSections(/docs\/?/g, /\d+:/g, ""),
26+
path: computePath('/', /\d+:/g, ''),
27+
sections: computeSections(/docs\/?/g, /\d+:/g, ''),
2628
contentHeadings: computeContentHeadings(),
2729
},
2830
}));
2931

3032
/** @type {ContentedConfig} */
3133
export default {
32-
preview: {
33-
url: "https://contented.dev",
34-
name: "Contented Documentation",
35-
github: {
36-
url: "https://github.com/BirthdayResearch/contented",
37-
},
38-
},
39-
processor: {
40-
rootDir: "./",
41-
types: [Doc],
42-
},
34+
rootDir: './',
35+
unified: getUnifiedProcessor,
36+
types: [Doc],
4337
};

packages/contented-example/docs/03:Jellyfish/02-design.md

+10-28
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ A `Promise<?>` based design is used as async/await implementation are very matur
99
life to modern development.
1010

1111
```js
12-
import { JsonRpcClient } from "@defichain/jellyfish-api-jsonrpc";
12+
import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc';
1313

14-
const client = new JsonRpcClient("http://foo:bar@localhost:8554");
14+
const client = new JsonRpcClient('http://foo:bar@localhost:8554');
1515
const { blocks } = await client.mining.getMiningInfo();
1616
```
1717

@@ -21,10 +21,10 @@ Due to the dynamic nature of the JavaScript language, it forces all number to be
2121
cause precision to be lost. [JellyfishSDK/jellyfish/issues/18](https://github.com/JellyfishSDK/jellyfish/issues/18)
2222

2323
```js
24-
it("lost precision converting DFI 😥", () => {
24+
it('lost precision converting DFI 😥', () => {
2525
const n = 1200000000.00000001;
2626
const a = JSON.parse(JSON.stringify(n)) * 1.0e8;
27-
expect(a.toString()).toStrictEqual("120000000000000001");
27+
expect(a.toString()).toStrictEqual('120000000000000001');
2828
});
2929
```
3030

@@ -51,15 +51,8 @@ wallet or transaction related operations. While IEEE-754 number is used for all
5151

5252
```ts {3}
5353
export class Wallet {
54-
async getBalance(
55-
minimumConfirmation: number = 0,
56-
includeWatchOnly: boolean = false
57-
): Promise<BigNumber> {
58-
return await this.client.call(
59-
"getbalance",
60-
["*", minimumConfirmation, includeWatchOnly],
61-
"bignumber"
62-
);
54+
async getBalance(minimumConfirmation: number = 0, includeWatchOnly: boolean = false): Promise<BigNumber> {
55+
return await this.client.call('getbalance', ['*', minimumConfirmation, includeWatchOnly], 'bignumber');
6356
}
6457
}
6558
```
@@ -72,19 +65,12 @@ export interface MiningInfo {
7265
}
7366

7467
export class Mining {
75-
async getNetworkHashPerSecond(
76-
nblocks: number = 120,
77-
height: number = -1
78-
): Promise<number> {
79-
return await this.client.call(
80-
"getnetworkhashps",
81-
[nblocks, height],
82-
"number"
83-
);
68+
async getNetworkHashPerSecond(nblocks: number = 120, height: number = -1): Promise<number> {
69+
return await this.client.call('getnetworkhashps', [nblocks, height], 'number');
8470
}
8571

8672
async getMiningInfo(): Promise<MiningInfo> {
87-
return await this.client.call("getmininginfo", [], "number");
73+
return await this.client.call('getmininginfo', [], 'number');
8874
}
8975
}
9076
```
@@ -116,10 +102,6 @@ export abstract class ApiClient {
116102
* @throws RpcApiError
117103
* @throws ClientApiError
118104
*/
119-
abstract call<T>(
120-
method: string,
121-
params: any[],
122-
precision: Precision
123-
): Promise<T>;
105+
abstract call<T>(method: string, params: any[], precision: Precision): Promise<T>;
124106
}
125107
```

packages/contented-example/docs/03:Jellyfish/03-usage.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ npm i defichain @defichain/jellyfish-api-jsonrpc
1111
## JsonRpcClient
1212

1313
```ts
14-
import { JsonRpcClient } from "@defichain/jellyfish-api-jsonrpc";
14+
import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc';
1515

16-
const client = new JsonRpcClient("http://foo:bar@localhost:8554");
16+
const client = new JsonRpcClient('http://foo:bar@localhost:8554');
1717
```
1818

1919
## ApiClient
2020

2121
You can extend `ApiClient` with the `@defichain/jellyfish-api-core` package to create your own transport exchange specification.
2222

2323
```ts
24-
import { ApiClient } from "@defichain/jellyfish-api-core";
24+
import { ApiClient } from '@defichain/jellyfish-api-core';
2525

2626
class SpecClient extends ApiClient {
2727
async call<T>(method: string, payload: any[]): Promise<T> {
28-
throw new ClientApiError("error from client");
28+
throw new ClientApiError('error from client');
2929
}
3030
}
3131

32-
const client = new SpecClient("http://localhost:8554");
32+
const client = new SpecClient('http://localhost:8554');
3333
```
3434

3535
## `call` Method
@@ -41,5 +41,5 @@ You can use the `.call` method directly by specifying:
4141
3. number precision for parse
4242

4343
```ts
44-
const result = await client.call("methodname", ["p1", "p2"], "number");
44+
const result = await client.call('methodname', ['p1', 'p2'], 'number');
4545
```

packages/contented-example/docs/05:introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ As with all modern JavaScript projects, jellyfish follows a monorepo structure w
1515
maintained in this repo are published with the same version tag and follows the `DeFiCh/ain` releases.
1616

1717
| Package | Description |
18-
|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
18+
| -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
1919
| `@defichain/jellyfish-address` | Provide address builder, parser, validator utility library for DeFi Blockchain. |
2020
| `@defichain/jellyfish-api-core` | A protocol agnostic DeFi Blockchain client interfaces, with a "foreign function interface" design. |
2121
| `@defichain/jellyfish-api-jsonrpc` | Implements the [JSON-RPC 1.0](https://www.jsonrpc.org/specification_v1) specification for api-core. |

0 commit comments

Comments
 (0)