Skip to content

Commit 3e11dcb

Browse files
authored
feat: initial T-Ruby WASM npm package setup (#1)
* feat: initial T-Ruby WASM npm package setup - @t-ruby/wasm package for browser-based T-Ruby compilation - TypeScript API with full type definitions - Ruby WASM integration (@ruby/3.4-wasm-wasi) - Virtual file system for multi-file projects - GitHub Actions CI/CD workflows - Version synced with t-ruby gem (0.0.46) * fix(ci): remove npm cache option (no package-lock.json) * fix(types): resolve TypeScript compilation errors - Fix 'success' property duplication in compile() return - Use @ruby/wasm-wasi/dist/browser for DefaultRubyVM import - Add @ts-expect-error for untyped browser subpath * fix(types): remove unused ts-expect-error directive * fix(lint): migrate to ESLint v9 flat config - Add eslint.config.js with flat config format - Add @eslint/js and typescript-eslint dependencies - Remove deprecated .eslintrc.cjs - Update lint script (remove --ext flag) * feat(release): use npm Trusted Publishing (OIDC) - Add id-token permission for OIDC authentication - Remove NPM_TOKEN secret dependency - Enable --provenance for supply chain security
1 parent 2acba68 commit 3e11dcb

37 files changed

+1856
-1
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
20+
- name: Install dependencies
21+
run: npm install
22+
23+
- name: Type check
24+
run: npm run typecheck
25+
26+
- name: Lint
27+
run: npm run lint
28+
29+
- name: Build
30+
run: npm run build
31+
32+
- name: Test
33+
run: npm run test:run

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'WASM version (e.g., 0.0.46.1)'
11+
required: true
12+
t_ruby_version:
13+
description: 't-ruby version (e.g., 0.0.46, defaults to latest)'
14+
required: false
15+
16+
permissions:
17+
contents: write
18+
id-token: write
19+
20+
jobs:
21+
publish:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
registry-url: 'https://registry.npmjs.org'
30+
31+
- name: Install dependencies
32+
run: npm install
33+
34+
- name: Extract version
35+
id: version
36+
run: |
37+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
38+
VERSION="${{ inputs.version }}"
39+
T_RUBY_VERSION="${{ inputs.t_ruby_version }}"
40+
else
41+
VERSION=${GITHUB_REF#refs/tags/v}
42+
T_RUBY_VERSION=""
43+
fi
44+
echo "version=$VERSION" >> $GITHUB_OUTPUT
45+
echo "t_ruby_version=$T_RUBY_VERSION" >> $GITHUB_OUTPUT
46+
echo "Publishing version: $VERSION"
47+
48+
- name: Build
49+
run: npm run build
50+
51+
- name: Update version
52+
run: npm version ${{ steps.version.outputs.version }} --no-git-tag-version --allow-same-version
53+
54+
- name: Publish to npm
55+
run: npm publish --access public --provenance
56+
57+
- name: Create Release
58+
uses: softprops/action-gh-release@v2
59+
with:
60+
name: "v${{ steps.version.outputs.version }}"
61+
generate_release_notes: true
62+
files: |
63+
dist/*
64+
package.json

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
7+
# IDE
8+
.idea/
9+
.vscode/
10+
*.swp
11+
*.swo
12+
*~
13+
14+
# OS
15+
.DS_Store
16+
Thumbs.db
17+
18+
# Logs
19+
*.log
20+
npm-debug.log*
21+
22+
# Test coverage
23+
coverage/
24+
25+
# Environment
26+
.env
27+
.env.local
28+
.env.*.local
29+
30+
# Temporary files
31+
tmp/
32+
temp/
33+
*.tmp
34+
35+
# Package manager locks (optional, uncomment if not using)
36+
# package-lock.json
37+
# yarn.lock
38+
# pnpm-lock.yaml

CONTRIBUTING.ko.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# T-Ruby WASM 기여 가이드
2+
3+
> [English Documentation](./CONTRIBUTING.md)
4+
5+
T-Ruby WASM에 기여해 주셔서 감사합니다! 이 문서는 기여자를 위한 가이드라인과 정보를 제공합니다.
6+
7+
## 행동 강령
8+
9+
모든 상호작용에서 존중과 건설적인 태도를 유지해 주세요. 모든 배경과 경험 수준의 기여자를 환영합니다.
10+
11+
## 시작하기
12+
13+
1. 저장소를 포크하세요
14+
2. 포크한 저장소를 클론하세요:
15+
```bash
16+
git clone https://github.com/YOUR_USERNAME/t-ruby-wasm.git
17+
cd t-ruby-wasm
18+
```
19+
3. 의존성을 설치하세요:
20+
```bash
21+
npm install
22+
```
23+
4. 변경사항을 위한 브랜치를 생성하세요:
24+
```bash
25+
git checkout -b feature/your-feature-name
26+
```
27+
28+
## 개발 가이드라인
29+
30+
### 코드 스타일
31+
32+
- 모든 소스 파일에 TypeScript 사용
33+
- 기존 코드 스타일 준수
34+
- 각 파일은 하나의 export만 가져야 함
35+
- 파일은 100줄 미만으로 유지 (주석 포함)
36+
- 종합적인 JSDoc 주석 작성
37+
38+
### SOLID 원칙
39+
40+
SOLID 원칙을 따릅니다:
41+
42+
- **S**ingle Responsibility: 각 클래스/모듈은 하나의 책임만
43+
- **O**pen/Closed: 확장에 열려있고 수정에 닫혀있음
44+
- **L**iskov Substitution: 서브타입은 대체 가능해야 함
45+
- **I**nterface Segregation: 인터페이스를 작고 집중적으로 유지
46+
- **D**ependency Inversion: 추상화에 의존
47+
48+
### DRY 원칙
49+
50+
같은 코드를 반복하지 마세요. 공통 로직은 재사용 가능한 유틸리티로 추출하세요.
51+
52+
## 테스팅
53+
54+
### 테스트 주도 개발 (TDD)
55+
56+
TDD 방법론을 사용합니다:
57+
58+
1. 먼저 실패하는 테스트 작성
59+
2. 테스트를 통과하는 최소한의 코드 작성
60+
3. 테스트를 통과 상태로 유지하면서 리팩토링
61+
62+
### 테스트 실행
63+
64+
```bash
65+
# 테스트 실행
66+
npm test
67+
68+
# 감시 모드로 테스트 실행
69+
npm run test:watch
70+
71+
# 커버리지와 함께 테스트 실행
72+
npm run test:coverage
73+
```
74+
75+
## Pull Request 과정
76+
77+
1. 모든 테스트가 통과하는지 확인
78+
2. 필요한 경우 문서 업데이트
79+
3. 새 기능에 대한 테스트 추가
80+
4. 커밋은 원자적이고 설명이 잘 되어야 함
81+
5. 관련 이슈 참조
82+
83+
### 커밋 메시지 형식
84+
85+
```
86+
type: 짧은 설명
87+
88+
필요한 경우 더 긴 설명.
89+
90+
Fixes #123
91+
```
92+
93+
타입: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
94+
95+
## 프로젝트 구조
96+
97+
```
98+
t-ruby-wasm/
99+
├── src/
100+
│ ├── types/ # 타입 정의 (파일당 하나)
101+
│ ├── vm/ # Ruby VM 관련 코드
102+
│ ├── utils/ # 유틸리티 함수
103+
│ ├── TRuby.ts # 메인 TRuby 클래스
104+
│ ├── createTRuby.ts # 팩토리 함수
105+
│ ├── VirtualFileSystem.ts
106+
│ └── index.ts # 공개 exports
107+
├── tests/ # 테스트 파일
108+
├── scripts/ # 빌드 스크립트
109+
└── dist/ # 빌드 출력
110+
```
111+
112+
## 질문이 있으신가요?
113+
114+
질문이나 논의를 위해 이슈를 열어주세요.

CONTRIBUTING.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Contributing to T-Ruby WASM
2+
3+
> [한국어 문서](./CONTRIBUTING.ko.md)
4+
5+
Thank you for your interest in contributing to T-Ruby WASM! This document provides guidelines and information for contributors.
6+
7+
## Code of Conduct
8+
9+
Please be respectful and constructive in all interactions. We welcome contributors of all backgrounds and experience levels.
10+
11+
## Getting Started
12+
13+
1. Fork the repository
14+
2. Clone your fork:
15+
```bash
16+
git clone https://github.com/YOUR_USERNAME/t-ruby-wasm.git
17+
cd t-ruby-wasm
18+
```
19+
3. Install dependencies:
20+
```bash
21+
npm install
22+
```
23+
4. Create a branch for your changes:
24+
```bash
25+
git checkout -b feature/your-feature-name
26+
```
27+
28+
## Development Guidelines
29+
30+
### Code Style
31+
32+
- Use TypeScript for all source files
33+
- Follow the existing code style
34+
- Each file should have a single export
35+
- Keep files under 100 lines (including comments)
36+
- Write comprehensive JSDoc comments
37+
38+
### SOLID Principles
39+
40+
We follow SOLID principles:
41+
42+
- **S**ingle Responsibility: Each class/module has one responsibility
43+
- **O**pen/Closed: Open for extension, closed for modification
44+
- **L**iskov Substitution: Subtypes must be substitutable
45+
- **I**nterface Segregation: Keep interfaces small and focused
46+
- **D**ependency Inversion: Depend on abstractions
47+
48+
### DRY Principle
49+
50+
Don't Repeat Yourself. Extract common logic into reusable utilities.
51+
52+
## Testing
53+
54+
### Test-Driven Development (TDD)
55+
56+
We use TDD methodology:
57+
58+
1. Write a failing test first
59+
2. Write the minimum code to pass the test
60+
3. Refactor while keeping tests green
61+
62+
### Running Tests
63+
64+
```bash
65+
# Run tests
66+
npm test
67+
68+
# Run tests in watch mode
69+
npm run test:watch
70+
71+
# Run tests with coverage
72+
npm run test:coverage
73+
```
74+
75+
## Pull Request Process
76+
77+
1. Ensure all tests pass
78+
2. Update documentation if needed
79+
3. Add tests for new functionality
80+
4. Keep commits atomic and well-described
81+
5. Reference any related issues
82+
83+
### Commit Message Format
84+
85+
```
86+
type: short description
87+
88+
Longer description if needed.
89+
90+
Fixes #123
91+
```
92+
93+
Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
94+
95+
## Project Structure
96+
97+
```
98+
t-ruby-wasm/
99+
├── src/
100+
│ ├── types/ # Type definitions (one per file)
101+
│ ├── vm/ # Ruby VM related code
102+
│ ├── utils/ # Utility functions
103+
│ ├── TRuby.ts # Main TRuby class
104+
│ ├── createTRuby.ts # Factory function
105+
│ ├── VirtualFileSystem.ts
106+
│ └── index.ts # Public exports
107+
├── tests/ # Test files
108+
├── scripts/ # Build scripts
109+
└── dist/ # Build output
110+
```
111+
112+
## Questions?
113+
114+
Feel free to open an issue for questions or discussions.

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
BSD 2-Clause License
2+
3+
Copyright (c) 2024-2025, Y. Fred Kim
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)