Skip to content

Commit 53ec620

Browse files
committed
fix: failing test (currently: 27 passing 15 failing)
1 parent e0c1aa8 commit 53ec620

32 files changed

+1236
-839
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
sourceType: 'module'
1515
},
1616
rules: {
17-
'@typescript-eslint/no-unused-vars': 'error',
17+
'@typescript-eslint/no-unused-vars': 'warn',
1818
'@typescript-eslint/explicit-function-return-type': 'warn',
1919
'@typescript-eslint/no-explicit-any': 'warn',
2020
'prefer-const': 'error',
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ name: Deploy GitHub Pages
22

33
on:
44
push:
5-
branches:
6-
- master
7-
paths: ['docs/**']
5+
branches: [main, master]
86
workflow_dispatch:
97

108
permissions:

.github/workflows/test-build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Test & Build
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
test-build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Bun
18+
uses: oven-sh/setup-bun@v1
19+
20+
- name: Install dependencies
21+
run: bun install
22+
23+
- name: Build library
24+
run: bun run build
25+
26+
- name: Run tests
27+
run: bun test

FAILING_TESTS.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# FAILING_TESTS
2+
3+
## Type Generator
4+
- [ ] Convert function types: Function return type is `any` instead of the correct type (should be `boolean`, `number`, etc.).
5+
- [ ] Convert method types: Method signatures are not correctly omitting `self` and/or return type is not correct.
6+
- [ ] Comment Preservation: Single-line and multi-line comments are not preserved in the generated TypeScript.
7+
- [ ] Advanced Type Conversion: Union types with object literals are not handled correctly.
8+
- [ ] Advanced Type Conversion: Functions with multiple parameters are not handled correctly.
9+
- [ ] Type Generator Options: `useUnknown` does not output `unknown` as expected.
10+
- [ ] Type Generator Options: `interfacePrefix` does not prefix interface names as expected.
11+
- [ ] Type Generator Options: `semicolons` option does not control semicolon output as expected.
12+
13+
## Error Handling
14+
- [ ] Syntax errors are not always detected (test expects errors, but none are reported).
15+
16+
## Snapshot Tests
17+
- [ ] Game types snapshot does not match expected output (likely due to comment or type conversion issues).
18+
19+
## CLI Tools
20+
- [ ] Convert a single file: Output file is not generated or does not contain expected content.
21+
- [ ] Convert a directory: Output files are not generated or do not contain expected content.
22+
- [ ] Validate a file: CLI does not validate file as expected.
23+
- [ ] Use config file: CLI does not respect config file options.
24+
25+
## Plugins
26+
- [ ] Plugin system: Plugin transforms are not applied as expected (e.g., type transforms, added fields).
27+
28+
---
29+
**Note:**
30+
- Some failures are due to missing or incomplete features (e.g., plugin system, comment preservation).
31+
- Some failures are due to incorrect or missing type conversions (especially for function and method types).
32+
- Some failures are due to CLI not being fully implemented or not matching test expectations.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131

3232
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.
3333

34+
> [!CAUTION]
35+
> This lib is still a work in progress, as such you WILL NOT find it on NPM yet!
36+
3437
## ✨ Features
3538

3639
- 🔁 **Converts Lua/Luau type declarations into TypeScript interfaces**
@@ -114,6 +117,43 @@ Visit **[luats.codemeapixel.dev](https://luats.codemeapixel.dev)** for comprehen
114117
- [Examples](https://luats.codemeapixel.dev/examples)
115118
- [Contributing Guide](https://luats.codemeapixel.dev/contributing)
116119

120+
## 🛠 CLI Usage
121+
122+
The CLI supports converting files and directories:
123+
124+
```bash
125+
npx luats convert src/file.lua -o src/file.d.ts
126+
npx luats dir src/lua -o src/types
127+
```
128+
129+
### CLI Options
130+
131+
| Option | Alias | Description |
132+
| -------------- | ----- | --------------------------------- |
133+
| --input | -i | Input file or directory |
134+
| --output | -o | Output file or directory |
135+
| --config | -c | Path to config file |
136+
| --silent | -s | Suppress output messages |
137+
| --verbose | -v | Verbose output |
138+
| --watch | -w | Watch for file changes |
139+
140+
### Configuration File
141+
142+
You can use a `luats.config.json` or `.luatsrc.json` file to specify options:
143+
144+
```json
145+
{
146+
"outDir": "./types",
147+
"include": ["**/*.lua", "**/*.luau"],
148+
"exclude": ["**/node_modules/**", "**/dist/**"],
149+
"plugins": [],
150+
"typeGeneratorOptions": {
151+
"exportTypes": true,
152+
"generateComments": true
153+
}
154+
}
155+
```
156+
117157
## 🤝 Contributing
118158

119159
Contributions are welcome! Please feel free to submit a Pull Request.

TODO.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# TODO Checklist
2+
3+
- [x] **Fix all TypeScript build errors and warnings**
4+
- [x] Remove duplicate/unused functions and variables
5+
- [x] Correct all type/interface issues (especially optional properties)
6+
- [x] Ensure all imports are correct and used
7+
- [x] **Implement real Lua/Luau parsing in `generateTypeScript`**
8+
- [x] Integrate or stub a parser for Lua/Luau AST generation
9+
- [x] **Add proper plugin loading and application in CLI processor**
10+
- [x] Remove duplicate `applyPlugins` and implement dynamic plugin loading
11+
- [x] **Expand CLI validation logic beyond placeholder**
12+
- [x] Add real validation for Lua/Luau files
13+
- [ ] **Write unit tests for CLI and processor modules**
14+
- [ ] Cover CLI commands and processor logic
15+
- [ ] **Improve error handling and user feedback in CLI**
16+
- [ ] Make CLI output clear and actionable
17+
- [x] **Document configuration options and CLI usage**
18+
- [x] Add README and CLI help improvements
19+
- [ ] **Add support for more CLI commands (e.g., format, lint)**
20+
- [ ] **Ensure cross-platform compatibility (Windows, Linux, macOS)**
21+
- [ ] Replace `rm -rf` with cross-platform alternatives (e.g., `rimraf`)
22+
- [ ] **Set up CI for automated builds and tests**
23+
- [ ] Add GitHub Actions or similar workflow
24+
25+
---
26+
27+
## Additional Ideas & Improvements
28+
29+
- [ ] **Publish TypeScript declaration files (`.d.ts`) for all public APIs**
30+
- [ ] **Add ESM and CJS dual support with proper `"exports"` field**
31+
- [ ] **Provide a VSCode extension for Lua/Luau → TypeScript conversion**
32+
- [ ] **Add support for custom output templates (e.g., for JSDoc, TSDoc, etc.)**
33+
- [ ] **Enable incremental builds for large codebases**
34+
- [ ] **Support for Lua 5.4 and future Luau features**
35+
- [ ] **Add a web playground (REPL) for live conversion and preview**
36+
- [ ] **Add a `luats init` command to scaffold config and example files**
37+
- [ ] **Support for YAML config files in addition to JSON**
38+
- [ ] **Add CLI auto-completion scripts for bash/zsh/fish**
39+
- [ ] **Improve error messages with code frames and suggestions**
40+
- [ ] **Add a `luats watch` mode for live conversion in dev workflows**
41+
- [ ] **Provide migration guides for legacy Lua codebases**
42+
- [ ] **Add benchmarking and performance tests**
43+
- [ ] **Support for sourcemaps or code mapping back to Lua**
44+
- [ ] **Add a logo/banner to npm and GitHub README**
45+
- [ ] **Add badges for test coverage, bundle size, etc.**
46+
- [ ] **Publish example projects and templates**
47+
- [ ] **Add a `luats doctor` command for troubleshooting environment/config issues**
48+
- [ ] **Support for monorepo setups and workspace-aware config**
49+
- [ ] **Add support for extern types/classes (typically ending in a .d.lua file)**
50+
- [ ] **Add ability to reverse logic (ie: transform typescript into lua)**

docs/_includes/head_custom.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
<meta property="og:title" content="LuaTS - TypeScript Library for Lua and Luau" />
1010
<meta property="og:description" content="A comprehensive TypeScript library for parsing, formatting, analyzing, and transforming Lua and Luau code with robust type interfaces and AST manipulation" />
1111
<meta property="og:type" content="website" />
12-
<meta property="og:url" content="https://codemeapixel.github.io/luats" />
13-
<meta property="og:image" content="https://codemeapixel.github.io/luats/assets/assets/banner.png" />
12+
<meta property="og:url" content="https://luats.codemeapixel.dev" />
13+
<meta property="og:image" content="/assets/banner.png" />
1414

1515
<!-- Twitter Card -->
1616
<meta name="twitter:card" content="summary_large_image" />
1717
<meta name="twitter:title" content="LuaTS - TypeScript Library for Lua and Luau" />
1818
<meta name="twitter:description" content="A comprehensive TypeScript library for parsing, formatting, analyzing, and transforming Lua and Luau code with robust type interfaces and AST manipulation" />
19-
<meta name="twitter:image" content="https://codemeapixel.github.io/luats/assets/banner.png" />
19+
<meta name="twitter:image" content="/assets/banner.png" />
2020
<meta name="twitter:site" content="@CodeMeAPixel" />
2121
<meta name="twitter:creator" content="@CodeMeAPixel" />
2222

examples/plugin-demo.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { parseLuau, generateTypes, generateTypesWithPlugins } from '../src/index';
22
import ReadonlyPlugin from './readonly-plugin';
33
import { loadPlugins, applyPlugins } from '../src/plugins/plugin-system';
4-
import { TypeGenerator } from '../src/generators/typescript';
4+
import { TypeGenerator } from '../src/generators';
55

66
// Example Luau code with type definitions
77
const luauCode = `
@@ -33,8 +33,7 @@ type GameEvent = {
3333
async function runDemo() {
3434
console.log('=== Parsing Luau Code ===');
3535
try {
36-
const parser = new parseLuau();
37-
const ast = parser.parse(luauCode);
36+
const ast = parseLuau(luauCode);
3837
console.log('✅ Successfully parsed AST');
3938
console.log(`Found ${ast.body.length} top-level statements`);
4039
} catch (error) {
@@ -56,21 +55,20 @@ async function runDemo() {
5655
const typesWithPlugin = await generateTypesWithPlugins(
5756
luauCode,
5857
{ useUnknown: true },
59-
['./examples/readonly-plugin.js'] // This would work if the plugin is compiled to JS
58+
['./examples/readonly-plugin.js']
6059
);
6160

6261
// Method 2: Manual plugin application (for demonstration)
63-
const parser = new parseLuau();
62+
const ast = parseLuau(luauCode);
6463
const generator = new TypeGenerator({ generateComments: true });
65-
const ast = parser.parse(luauCode);
6664

6765
// Apply the plugin directly
6866
applyPlugins(generator, [ReadonlyPlugin], {
6967
typeGeneratorOptions: { generateComments: true },
7068
config: { preserveComments: true, commentStyle: 'jsdoc' }
7169
});
7270

73-
const typesWithManualPlugin = generator.generateFromLuauAST(ast);
71+
const typesWithManualPlugin = generator.generateTypeScript(ast);
7472

7573
console.log('✅ Generated TypeScript interfaces with readonly plugin:');
7674
console.log(typesWithManualPlugin);

src/cli/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface LuatsConfig {
4242

4343
// Logging options
4444
verbose?: boolean;
45+
silent?: boolean;
4546
}
4647

4748
/**
@@ -74,7 +75,8 @@ export const defaultConfig: LuatsConfig = {
7475

7576
plugins: [],
7677

77-
verbose: false
78+
verbose: false,
79+
silent: false
7880
};
7981

8082
/**

0 commit comments

Comments
 (0)