Skip to content

Commit

Permalink
feat: 新增类型文件
Browse files Browse the repository at this point in the history
  • Loading branch information
CalmLexi committed Jun 29, 2024
1 parent 1e68df3 commit 161d037
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@ jobs:
with:
submodules: recursive

- name: Setup Node.js
- name: 设置 Node.js
uses: actions/setup-node@v2
with:
node-version: 16
node-version: 20
registry-url: "https://registry.npmjs.org/"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

- name: Install protobufjs globally
- name: 全局安装 typescript
run: npm install -g typescript

- name: 编译index.ts
run: tsc

- name: 全局安装 protobufjs-cli
run: npm install -g protobufjs-cli

- name: Build
- name: 编译 proto
run: npm run build

- name: Publish to NPM
- name: 推送到 npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules/
package-lock.json
protos/compiled.d.ts
protos/compiled.js
pnpm-lock.yaml
index.d.ts
3 changes: 3 additions & 0 deletions index.js → index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { fileURLToPath } from 'url'
import protobufjs from 'protobufjs'

const filePath = fileURLToPath(import.meta.url)
/**
* - proto 文件路径
*/
const proto = path.dirname(filePath) + '/kritor/protos'

export { protobufjs, proto }
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
"type": "module",
"main": "index.js",
"author": "CalmLexi",
"description": "Kritor Proto for Node.js",
"homepage": "https://github.com/KarinJS/node-kritor",
"bugs": {
"url": "https://github.com/KarinJS/node-kritor/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/KarinJS/node-kritor.git"
},
"dependencies": {
"protobufjs": "^7.3.0"
},
"files": [
"protos/",
"kritor/",
"index.js",
"index.d.ts",
".gitmodules",
"package.json"
],
Expand Down
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "ES6",
"module": "nodenext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"declaration": true,
"forceConsistentCasingInFileNames": true,
"outDir": ".",
"typeRoots": ["./node_modules/@types"],
"types": ["node"]
},
"include": ["index.ts"],
"exclude": ["node_modules", "dist"]
}

0 comments on commit 161d037

Please sign in to comment.