Skip to content

Commit 8d54eb3

Browse files
committed
feat(add): initial commit
0 parents  commit 8d54eb3

Some content is hidden

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

65 files changed

+9344
-0
lines changed

.eslintrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
plugins: ['@typescript-eslint'],
4+
extends: [
5+
'eslint:recommended',
6+
'@typescript-eslint/recommended'
7+
],
8+
env: {
9+
node: true,
10+
es2022: true
11+
},
12+
parserOptions: {
13+
ecmaVersion: 2022,
14+
sourceType: 'module'
15+
},
16+
rules: {
17+
'@typescript-eslint/no-unused-vars': 'error',
18+
'@typescript-eslint/explicit-function-return-type': 'warn',
19+
'@typescript-eslint/no-explicit-any': 'warn',
20+
'prefer-const': 'error',
21+
'no-var': 'error'
22+
}
23+
};

.github/workflows/docs.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'docs/**'
9+
- '.github/workflows/docs.yml'
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
18+
- name: Setup Ruby
19+
uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: '3.0'
22+
bundler-cache: true
23+
24+
- name: Install Jekyll
25+
run: |
26+
gem install jekyll bundler
27+
bundle install
28+
29+
- name: Build Jekyll site
30+
run: |
31+
cd docs
32+
bundle exec jekyll build
33+
34+
- name: Deploy
35+
uses: JamesIves/github-pages-deploy-action@v4
36+
with:
37+
folder: docs/_site
38+
branch: gh-pages
39+
clean: true

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
dist/
3+
*.log
4+
.env
5+
.DS_Store
6+
Thumbs.db
7+
*.tsbuildinfo

.npmignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Development files
2+
src/
3+
test/
4+
examples/
5+
docs/
6+
.github/
7+
coverage/
8+
.vscode/
9+
.idea/
10+
.git/
11+
12+
# Only include the logo in assets
13+
assets/
14+
!assets/logo.png
15+
16+
# Configuration files (except those needed for package users)
17+
.eslintrc.js
18+
.prettierrc
19+
.gitignore
20+
.travis.yml
21+
tsconfig.json
22+
bunfig.toml
23+
Gemfile
24+
bun.lockb
25+
jest.config.js
26+
27+
# Build artifacts
28+
*.log
29+
*.tsbuildinfo
30+
.DS_Store
31+
Thumbs.db
32+
33+
# Test files
34+
__tests__/
35+
__mocks__/
36+
*.test.ts
37+
*.spec.ts
38+
39+
# Documentation files
40+
*.md
41+
!README.md
42+
!LICENSE
43+
!SECURITY.md
44+
!CHANGELOG.md
45+
46+
# Temporary files
47+
tmp/
48+
temp/
49+
.tmp/
50+
.temp/
51+
52+
# IDE configuration
53+
.editorconfig
54+
*.sublime-project
55+
*.sublime-workspace
56+
57+
# Only include dist folder when publishing
58+
# Don't ignore these files
59+
!dist/

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false
8+
}

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2025-07-11
9+
10+
### Added
11+
- Initial release of LuaTS
12+
- Support for parsing Lua and Luau code
13+
- AST generation and manipulation
14+
- TypeScript interface generation from Luau types
15+
- Type conversion between Lua/Luau and TypeScript
16+
- Support for optional types (foo: string? → foo?: string)
17+
- Support for table types ({string} → string[] or Record)
18+
- Conversion of Luau function types to TS arrow functions
19+
- Comment preservation and JSDoc formatting
20+
- CLI tool with file watching capabilities
21+
- Configuration file support
22+
- Plugin system for custom transformations
23+
- Basic inference for inline tables
24+
- Type definitions for exported API
25+
- Comprehensive test suite

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 Pixelated
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: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<div align="center">
2+
<img src="assets/logo.png" alt="LuaTS Logo" width="300" />
3+
</div>
4+
5+
<div align="center">
6+
7+
[![npm version](https://img.shields.io/npm/v/luats.svg?style=flat-square)](https://www.npmjs.org/package/luats)
8+
[![build status](https://img.shields.io/github/actions/workflow/status/codemeapixel/luats/ci.yml?branch=main&style=flat-square)](https://github.com/codemeapixel/luats/actions)
9+
[![npm downloads](https://img.shields.io/npm/dm/luats.svg?style=flat-square)](https://npm-stat.com/charts.html?package=luats)
10+
[![license](https://img.shields.io/npm/l/luats.svg?style=flat-square)](https://github.com/codemeapixel/luats/blob/main/LICENSE)
11+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
12+
13+
</div>
14+
15+
<p align="center">
16+
<b>A TypeScript library for parsing, formatting, and providing type interfaces for Lua and Luau code.</b>
17+
<br>
18+
<a href="https://luats.codemeapixel.dev"><strong>Explore the docs »</strong></a>
19+
<br>
20+
<br>
21+
<a href="https://luats.codemeapixel.dev/examples">View Examples</a>
22+
·
23+
<a href="https://github.com/codemeapixel/luats/issues/new?labels=bug&template=bug_report.md">Report Bug</a>
24+
·
25+
<a href="https://github.com/codemeapixel/luats/issues/new?labels=enhancement&template=feature_request.md">Request Feature</a>
26+
·
27+
<a href="https://github.com/codemeapixel/luats/security/policy">Security</a>
28+
</p>
29+
30+
## 🌟 What is LuaTS?
31+
32+
LuaTS bridges the gap between Lua/Luau and TypeScript ecosystems, allowing developers to leverage type safety while working with Lua codebases. Whether you're developing Roblox games, working with embedded Lua, or maintaining legacy Lua code, LuaTS helps you generate accurate TypeScript definitions for better IDE support, type checking, and developer experience.
33+
34+
## ✨ Features
35+
36+
- 🔁 **Converts Lua/Luau type declarations into TypeScript interfaces**
37+
- 🧠 **Maps Lua types to TypeScript equivalents** (`string`, `number`, etc.)
38+
-**Supports optional types** (`foo: string?``foo?: string`)
39+
- 🔧 **Handles table types** (`{string}``string[]` or `Record`)
40+
- ➡️ **Converts Luau function types to arrow functions in TS**
41+
- 📄 **Preserves comments and maps them to JSDoc format**
42+
- 📁 **Supports single-file or batch directory conversion**
43+
- 🛠 **Includes a CLI tool**:
44+
- `--out` / `-o` for output path
45+
- `--watch` for live file watching
46+
- `--silent` / `--verbose` modes
47+
- 🧪 **Validates syntax and reports conversion errors**
48+
- 🔌 **Optional config file** (`luats.config.json`)
49+
- 🔄 **Merges overlapping types or handles shared structures**
50+
- 📦 **Programmatic API** (`convertLuaToTS(code: string, options?)`)
51+
- 🧩 **Plugin hook system for custom transforms** (planned)
52+
- 🧠 **(Optional) Inference for inline tables to generate interfaces**
53+
- 📜 **Fully typed** (written in TS) with exported definitions
54+
- 🧪 **Test suite with snapshot/fixture testing**
55+
56+
## 📦 Installation
57+
58+
```bash
59+
# Using npm
60+
npm install luats
61+
62+
# Using yarn
63+
yarn add luats
64+
65+
# Using bun
66+
bun add luats
67+
```
68+
69+
## 🚀 Quick Start
70+
71+
```typescript
72+
import { LuaParser, LuaFormatter, TypeGenerator } from 'luats';
73+
74+
// Parse Lua code
75+
const parser = new LuaParser();
76+
const ast = parser.parse(`
77+
local function greet(name)
78+
return "Hello, " .. name
79+
end
80+
`);
81+
82+
// Generate TypeScript from Luau types
83+
const typeGen = new TypeGenerator();
84+
const tsCode = typeGen.generateTypeScript(`
85+
type Vector3 = {
86+
x: number,
87+
y: number,
88+
z: number
89+
}
90+
`);
91+
92+
console.log(tsCode);
93+
// Output: interface Vector3 { x: number; y: number; z: number; }
94+
```
95+
96+
## 💡 Use Cases
97+
98+
- **Roblox Development**: Generate TypeScript definitions from Luau types for better IDE support
99+
- **Game Development**: Maintain type safety when interfacing with Lua-based game engines
100+
- **Legacy Code Integration**: Add TypeScript types to existing Lua codebases
101+
- **API Type Definitions**: Generate TypeScript types for Lua APIs
102+
- **Development Tools**: Build better tooling for Lua/TypeScript interoperability
103+
104+
📚 **[Read the full documentation](https://luats.codemeapixel.dev)** for comprehensive guides, API reference, and examples.
105+
106+
## 📖 Documentation
107+
108+
Visit **[luats.codemeapixel.dev](https://luats.codemeapixel.dev)** for comprehensive documentation including:
109+
110+
- [Getting Started Guide](https://luats.codemeapixel.dev/getting-started)
111+
- [API Reference](https://luats.codemeapixel.dev/api-reference)
112+
- [CLI Usage](https://luats.codemeapixel.dev/cli)
113+
- [Plugin System](https://luats.codemeapixel.dev/plugins)
114+
- [Examples](https://luats.codemeapixel.dev/examples)
115+
- [Contributing Guide](https://luats.codemeapixel.dev/contributing)
116+
117+
## 🤝 Contributing
118+
119+
Contributions are welcome! Please feel free to submit a Pull Request.
120+
121+
1. Fork the repository
122+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
123+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
124+
4. Push to the branch (`git push origin feature/amazing-feature`)
125+
5. Open a Pull Request
126+
127+
See the [Contributing Guide](https://luats.codemeapixel.dev/contributing) for more information.
128+
129+
## 📄 License
130+
131+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

SECURITY.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 0.1.x | :white_check_mark: |
8+
9+
## Reporting a Vulnerability
10+
11+
We take the security of LuaTS seriously. If you believe you have found a security vulnerability, please follow these steps:
12+
13+
1. **Do not disclose the vulnerability publicly**
14+
2. **Email details to [[email protected]](mailto:[email protected])**
15+
- Provide a detailed description of the vulnerability
16+
- Include steps to reproduce the issue
17+
- Attach any proof-of-concept code if available
18+
- Suggest potential fixes or mitigations if you have them
19+
20+
## What to Expect
21+
22+
When you report a vulnerability:
23+
24+
- You'll receive an acknowledgment within 48 hours
25+
- We'll investigate and determine the potential impact
26+
- We'll work on a fix and release it as soon as possible
27+
- You'll be notified when the fix is released
28+
- We'll acknowledge your contribution (if desired) when we publish the fix
29+
30+
Thank you for helping keep LuaTS and its users secure!

0 commit comments

Comments
 (0)