Skip to content

Commit 9e47c4b

Browse files
committed
feat: merge cli and core
1 parent a7934a0 commit 9e47c4b

Some content is hidden

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

78 files changed

+412
-512
lines changed

.eslintrc.js

-30
This file was deleted.

.eslintrc.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 6,
4+
"sourceType": "module"
5+
},
6+
"parser": "@typescript-eslint/parser",
7+
"extends": [
8+
// add more generic rule sets here, such as:
9+
// 'eslint:recommended',
10+
"plugin:prettier/recommended",
11+
"plugin:svelte/recommended"
12+
],
13+
"rules": {
14+
// override/add rules settings here, such as:
15+
// 'svelte/rule-name': 'error'
16+
}
17+
}

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"skipFiles": [
1212
"<node_internals>/**"
1313
],
14-
"program": "${workspaceFolder}/packages/cli/tests/multiproto/multiproto.spec.js"
14+
"program": "${workspaceFolder}/packages/core/tests/print/enum.spec.js"
1515
}
1616
]
1717
}

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ A converter to transform from Protobuf to Typescript definition files, which is
1111
Protobuf is currently used in micro-service for back end. As a front end web developer, you can generate Typescript defination files based on Protobuf in case to develop your web page easily.
1212

1313
- [pbts](./packages/core)
14-
- [pbts-cli](./packages/cli)
1514
- [pbts-web](./packages/web)
1615
- [pbts-vscode](./packages/vscode)
1716

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
],
1515
"devDependencies": {
1616
"@changesets/cli": "^2.14.1",
17-
"@typescript-eslint/eslint-plugin": "^5.59.0",
18-
"@typescript-eslint/parser": "^5.59.0",
17+
"@typescript-eslint/eslint-plugin": "5.59.2",
18+
"@typescript-eslint/parser": "5.59.2",
1919
"svelte": "^3.58.0",
2020
"eslint": "^8.39.0",
21-
"eslint-plugin-svelte3": "^4.0.0",
21+
"eslint-plugin-svelte": "2.27.3",
2222
"eslint-config-prettier": "^8.8.0",
2323
"eslint-plugin-prettier": "^4.2.1",
2424
"prettier": "^2.8.7",

packages/cli/CHANGELOG.md

-31
This file was deleted.

packages/cli/README.md

-36
This file was deleted.

packages/cli/package.json

-53
This file was deleted.

packages/cli/pbts.config.js

-4
This file was deleted.

packages/cli/src/interface/config.d.ts

-5
This file was deleted.

packages/cli/src/utils/log.js

-8
This file was deleted.

packages/cli/tsconfig.json

-8
This file was deleted.

packages/core/CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# @pbts/core
1+
# pbts
2+
3+
## 4.0.0
4+
5+
### Major Changes
6+
7+
- merge cli and core repo
28

39
## 3.0.1
410

packages/core/README.md

+41-19
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,43 @@
33
[![NPM version][npm-image]][npm-url]
44
[![npm download][download-image]][download-url]
55

6-
[npm-image]: https://img.shields.io/npm/v/@pbts/core.svg?style=flat-square
7-
[npm-url]: https://www.npmjs.com/package/@pbts/core
8-
[download-image]: https://img.shields.io/npm/dm/@pbts/core.svg?style=flat-square
9-
[download-url]: https://www.npmjs.com/package/@pbts/core
6+
[npm-image]: https://img.shields.io/npm/v/pbts.svg?style=flat-square
7+
[npm-url]: https://www.npmjs.com/package/pbts
8+
[download-image]: https://img.shields.io/npm/dm/pbts.svg?style=flat-square
9+
[download-url]: https://www.npmjs.com/package/pbts
1010

11+
It is the cli for pbts. You can convert pb to ts file by command line
1112

12-
The core repo to convert protobuffer to typescript definition file.
13+
## CLI Usage
1314

14-
## Usage
15+
### Global Installation
16+
17+
step 1 Install pbts
18+
19+
```shell
20+
npm i pbts -g
21+
```
22+
23+
step 2 Convert your protobuffer to Typescript Definition File
24+
25+
```shell
26+
pbts -i input/app/order.proto -o output/order.ts
27+
```
28+
29+
### No Installation
30+
31+
Please use npx for short.
32+
33+
```shell
34+
npx pbts -i packages/cli/__tests__/__fixtures__/input/app/single.proto -o packages/cli/__tests__/__fixtures__/output/single.ts
35+
```
36+
37+
## Javascript API Usage
38+
39+
## Browser Library Usage
1540

1641
```javascript
17-
import { parseProto } from '@pbts/core';
42+
import { parseProto } from 'pbts/core';
1843

1944
const source = `
2045
syntax = "proto3";
@@ -34,20 +59,17 @@ interface MyRequest {
3459
}
3560
```
3661

37-
## Parameter
38-
39-
### Case 1 Typescript Definition File (.d.ts)
40-
41-
Default is false.
62+
## Node Library Usage
4263

4364
```javascript
44-
const ts = parseProto(source, {isDefinition: true});
45-
```
65+
import { parseProto } from 'pbts';
4666

47-
### Case 2 Request and Response Parameter (Optional)
48-
49-
Default is false.
67+
const source = `
68+
syntax = "proto3";
69+
message MyRequest {
70+
string path = 1;
71+
}
72+
`;
5073

51-
```javascript
52-
const ts = parseProto(source, {isParamOptional: true});
74+
const ts = parseProto(source);
5375
```

packages/cli/bin.js packages/core/bin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

33
import sade from 'sade';
4-
import convert from './src/index.js';
4+
import { convertCommand } from './src/index.js';
55
//@ts-ignore
66
import updater from 'pkg-updater';
77
import { readFile } from 'fs/promises';
@@ -21,7 +21,7 @@ updater({
2121
.example('-i test.proto -o test.ts')
2222
.option('-i, --input <env>', 'input file path')
2323
.option('-o, --output <env>', 'output file path')
24-
.action(convert);
24+
.action(convertCommand);
2525

2626
prog.parse(process.argv);
2727
});
File renamed without changes.

packages/cli/fixtures/output/product.ts packages/core/fixtures/output/product.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
import { ProductInfo } from './order';
3-
import { ErrorCode } from './order';
2+
import { ProductInfo } from 'order';
3+
import { ErrorCode } from 'order';
44

55
//Service: AppService
66
export type GetProduct = (params: GetProductReq) => Promise<GetProductResp>;

0 commit comments

Comments
 (0)