Skip to content

Commit ea90a20

Browse files
committed
feat: init
0 parents  commit ea90a20

16 files changed

Lines changed: 907 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: release
2+
on:
3+
push:
4+
# 监听 main 分支的 push 事件
5+
branches:
6+
- main
7+
# 赋予 release-please-action 权限
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
jobs:
12+
# 设置 release-please 任务
13+
release-please:
14+
# 设置任务运行环境为 ubuntu-latest
15+
runs-on: ubuntu-latest
16+
steps:
17+
# 使用 release-please-action 动作来自动创建发布 PR
18+
- uses: googleapis/release-please-action@v4
19+
id: release
20+
with:
21+
# 设置发布类型为 node
22+
release-type: node
23+
# 检出代码
24+
- uses: actions/checkout@v4
25+
if: ${{ steps.release.outputs.release_created }}
26+
# 设置 Node.js 环境
27+
- uses: actions/setup-node@v4
28+
with:
29+
# 设置 Node.js 版本
30+
node-version: 20
31+
# 设置 npm 源
32+
registry-url: "https://registry.npmjs.org"
33+
# 安装依赖
34+
- run: npm install
35+
if: ${{ steps.release.outputs.release_created }}
36+
# 下载编译完成的pty
37+
- run: npm run download
38+
if: ${{ steps.release.outputs.release_created }}
39+
# 构建输出
40+
- run: npm run download
41+
if: ${{ steps.release.outputs.release_created }}
42+
# 增加install script
43+
- run: npm pkg set "scripts.install"="node scripts/index.js"
44+
if: ${{ steps.release.outputs.release_created }}
45+
# 删除开发依赖
46+
- run: npm pkg delete devDependencies
47+
if: ${{ steps.release.outputs.release_created }}
48+
# 发布到 npm
49+
- run: npm run pub
50+
env:
51+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
if: ${{ steps.release.outputs.release_created }}

.gitignore

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2+
3+
# Logs
4+
5+
logs
6+
_.log
7+
npm-debug.log_
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Caches
14+
15+
.cache
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
19+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20+
21+
# Runtime data
22+
23+
pids
24+
_.pid
25+
_.seed
26+
*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
30+
lib-cov
31+
32+
# Coverage directory used by tools like istanbul
33+
34+
coverage
35+
*.lcov
36+
37+
# nyc test coverage
38+
39+
.nyc_output
40+
41+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42+
43+
.grunt
44+
45+
# Bower dependency directory (https://bower.io/)
46+
47+
bower_components
48+
49+
# node-waf configuration
50+
51+
.lock-wscript
52+
53+
# Compiled binary addons (https://nodejs.org/api/addons.html)
54+
55+
build/Release
56+
57+
# Dependency directories
58+
59+
node_modules/
60+
jspm_packages/
61+
62+
# Snowpack dependency directory (https://snowpack.dev/)
63+
64+
web_modules/
65+
66+
# TypeScript cache
67+
68+
*.tsbuildinfo
69+
70+
# Optional npm cache directory
71+
72+
.npm
73+
74+
# Optional eslint cache
75+
76+
.eslintcache
77+
78+
# Optional stylelint cache
79+
80+
.stylelintcache
81+
82+
# Microbundle cache
83+
84+
.rpt2_cache/
85+
.rts2_cache_cjs/
86+
.rts2_cache_es/
87+
.rts2_cache_umd/
88+
89+
# Optional REPL history
90+
91+
.node_repl_history
92+
93+
# Output of 'npm pack'
94+
95+
*.tgz
96+
97+
# Yarn Integrity file
98+
99+
.yarn-integrity
100+
101+
# dotenv environment variable files
102+
103+
.env
104+
.env.development.local
105+
.env.test.local
106+
.env.production.local
107+
.env.local
108+
109+
# parcel-bundler cache (https://parceljs.org/)
110+
111+
.parcel-cache
112+
113+
# Next.js build output
114+
115+
.next
116+
out
117+
118+
# Nuxt.js build / generate output
119+
120+
.nuxt
121+
dist
122+
123+
# Gatsby files
124+
125+
# Comment in the public line in if your project uses Gatsby and not Next.js
126+
127+
# https://nextjs.org/blog/next-9-1#public-directory-support
128+
129+
# public
130+
131+
# vuepress build output
132+
133+
.vuepress/dist
134+
135+
# vuepress v2.x temp and cache directory
136+
137+
.temp
138+
139+
# Docusaurus cache and generated files
140+
141+
.docusaurus
142+
143+
# Serverless directories
144+
145+
.serverless/
146+
147+
# FuseBox cache
148+
149+
.fusebox/
150+
151+
# DynamoDB Local files
152+
153+
.dynamodb/
154+
155+
# TernJS port file
156+
157+
.tern-port
158+
159+
# Stores VSCode versions used for testing VSCode extensions
160+
161+
.vscode-test
162+
163+
# yarn v2
164+
165+
.yarn/cache
166+
.yarn/unplugged
167+
.yarn/build-state.yml
168+
.yarn/install-state.gz
169+
.pnp.*
170+
171+
# IntelliJ based IDEs
172+
.idea
173+
174+
# Finder (MacOS) folder config
175+
.DS_Store
176+
lib
177+
dist
178+
pnpm-lock.yaml
179+
package-lock.json

.vscode/settings.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"editor.detectIndentation": false,
3+
"editor.tabSize": 2,
4+
"editor.formatOnSave": true,
5+
"editor.formatOnType": false,
6+
"editor.formatOnPaste": true,
7+
"editor.formatOnSaveMode": "file",
8+
"editor.codeActionsOnSave": {
9+
"source.fixAll.eslint": "always"
10+
},
11+
"explorer.fileNesting.enabled": true,
12+
"explorer.fileNesting.patterns": {
13+
".env": "*.env",
14+
"tsconfig.json": "tsconfig.*.json, env.d.ts, tsup.*.ts",
15+
"package.json": "package-lock.json, pnpm*, .yarnrc*, yarn*, .eslint*, eslint*, .prettier*, prettier*, .editorconfig, CHANGELOG.md, CODE_OF_CONDUCT.md, *.gitignore, LICENSE, README.md, .release*.json, .gitattributes"
16+
},
17+
"files.autoSave": "onFocusChange",
18+
"javascript.preferences.quoteStyle": "single",
19+
"typescript.preferences.quoteStyle": "single",
20+
"javascript.format.semicolons": "remove",
21+
"typescript.format.semicolons": "remove",
22+
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
23+
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
24+
"typescript.format.insertSpaceAfterConstructor": true,
25+
"javascript.format.insertSpaceAfterConstructor": true
26+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 时瑾
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# @karinjs/node-pty
2+

eslint.config.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import neostandard from 'neostandard'
2+
3+
/** 尾随逗号 */
4+
const commaDangle = val => {
5+
if (typeof val?.rules?.['@stylistic/comma-dangle']?.[1] === 'object') {
6+
val.rules['@stylistic/comma-dangle'][0] = 'off'
7+
Object.keys(val?.rules?.['@stylistic/comma-dangle']?.[1]).forEach(key => {
8+
val.rules['@stylistic/comma-dangle'][1][key] = 'always-multiline'
9+
})
10+
}
11+
12+
return val
13+
}
14+
15+
/** 忽略的文件 */
16+
const ignores = [
17+
'node_modules',
18+
'lib',
19+
'dist'
20+
]
21+
22+
const options = neostandard({
23+
ts: true,
24+
ignores,
25+
}).map(commaDangle)
26+
27+
export default options

package.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "@karinjs/node-pty",
3+
"main": "lib/index.js",
4+
"types": "lib/index.d.ts",
5+
"description": "node-pty without compilation",
6+
"keywords": [
7+
"node",
8+
"nodejs",
9+
"pty",
10+
"terminal",
11+
"shell",
12+
"process",
13+
"spawn"
14+
],
15+
"homepage": "https://github.com/KarinJS/node-pty",
16+
"bugs": {
17+
"url": "https://github.com/KarinJS/node-pty/issues"
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "git+https://github.com/KarinJS/node-pty.git"
22+
},
23+
"license": "MIT",
24+
"author": "shijin",
25+
"scripts": {
26+
"build": "tsup --tsconfig tsconfig.json --config tsup.config.ts",
27+
"download": "tsx src/index.ts"
28+
},
29+
"files": [
30+
"lib",
31+
"LICENSE",
32+
"package.json",
33+
"README.md"
34+
],
35+
"devDependencies": {
36+
"@types/decompress": "^4.2.7",
37+
"@types/node": "20",
38+
"axios": "^1.8.2",
39+
"decompress": "^4.2.1",
40+
"neostandard": "^0.12.1",
41+
"tsup": "^8.4.0",
42+
"tsx": "^4.19.3",
43+
"typescript": "^5.8.2"
44+
},
45+
"peerDependencies": {
46+
"typescript": "^5.0.0"
47+
},
48+
"engines": {
49+
"node": ">=16"
50+
},
51+
"publishConfig": {
52+
"access": "public",
53+
"registry": "https://registry.npmjs.org"
54+
}
55+
}

src/common/log.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const prefix = '[node-pty]'
2+
3+
/**
4+
* 简单的日志输出
5+
*/
6+
export const logger = {
7+
info (...msg: any[]) {
8+
console.log(`\x1b[32m${prefix}[info]\x1b[0m`, ...msg)
9+
},
10+
warn (...msg: any[]) {
11+
console.log(`\x1b[33m${prefix}[warn]\x1b[0m`, ...msg)
12+
},
13+
error (...msg: any[]) {
14+
console.log(`\x1b[31m${prefix}[error]\x1b[0m`, ...msg)
15+
},
16+
}

0 commit comments

Comments
 (0)