Skip to content

Commit 54de70f

Browse files
authored
Merge pull request #31 from attogram/feature/artisan-commands
feat: Add comprehensive suite of Artisan commands for lexicon management
2 parents ea425e4 + 3e53b64 commit 54de70f

74 files changed

Lines changed: 2166 additions & 284 deletions

File tree

Some content is hidden

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

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
- name: Run Tests
3737
run: composer test:log:all
3838

39+
- name: Run Static Analysis
40+
run: vendor/bin/phpstan analyse --memory-limit=2G
41+
3942
- name: Commit test results
4043
run: |
4144
git config --global user.name 'github-actions[bot]'

AGENTS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ During the initial setup, a persistent issue was encountered where running `arti
3232

3333
The test for the `ote:export-ote-file` command is brittle. The test's `expectsOutput` assertion fails when the command's success message is built using variables, even though the variables appear correct. To make the test pass, the success message in the `ExportOteFile` command has been hardcoded. This is a workaround, and the underlying issue with the test runner's output capturing has not been resolved.
3434

35+
### Laravel Dusk Integration
36+
37+
There are persistent issues with running Laravel Dusk in the development environment. The test runner (Pest) seems to have a conflict with how Dusk's test cases are discovered, and there are also issues with the ChromeDriver and Chrome binary setup.
38+
39+
After multiple attempts to fix these issues, the integration of Dusk has been abandoned for now.
40+
3541
---
3642

3743
## Agent-Specific Instructions

CONTRIBUTING.md

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,60 @@
11
# Contributing to Open Translation Engine (OTE) v2
22

3-
Thank you for considering contributing to the Open Translation Engine v2 project! We welcome all contributions, from bug reports and feature requests to code contributions.
3+
First off, thank you for considering contributing to OTE v2. It's people like you that make open source such a great community.
44

5-
## Why Contribute?
5+
## How Can I Contribute?
66

7-
OTE is a community-driven project. By contributing, you can help us build a better, more robust, and more user-friendly translation engine. Your contributions will benefit users and developers all over the world.
7+
### Reporting Bugs
88

9-
## How to Contribute
9+
If you find a bug, please open an issue on our [GitHub Issues](https://github.com/attogram/ote/issues) page. Please include as much detail as possible, including:
10+
- A clear and descriptive title.
11+
- A description of the problem.
12+
- Steps to reproduce the bug.
13+
- Any relevant screenshots or error messages.
1014

11-
### Reporting Bugs and Requesting Features
15+
### Suggesting Enhancements
1216

13-
If you find a bug or have an idea for a new feature, please open an issue on our [GitHub repository](https://github.com/attogram/ote/issues).
17+
If you have an idea for a new feature or an enhancement to an existing one, please open an issue on our [GitHub Issues](https://github.com/attogram/ote/issues) page. Please provide a clear and detailed explanation of the feature you're suggesting and why it would be valuable.
1418

15-
### Code Contributions
19+
### Your First Code Contribution
1620

17-
If you would like to contribute code, please follow these steps:
21+
Unsure where to begin contributing to OTE v2? You can start by looking through the `good-first-issue` and `help-wanted` issues.
1822

19-
1. **Fork the repository** and create your branch from `master`.
20-
2. **Set up your development environment** by following the instructions in `docs/jules.md`.
21-
3. **Make your changes** and write tests for them.
22-
4. **Ensure the tests pass** (if you are able to run them).
23-
5. **Create a pull request** with a clear description of your changes.
23+
## Development Workflow
2424

25-
If you are making changes to the deployment configuration, please refer to the [Render Deployment Guide](docs/RENDER.md) for more information on the setup.
25+
1. **Fork the repository** on GitHub.
26+
2. **Clone your fork** to your local machine.
27+
3. **Create a new branch** for your changes: `git checkout -b your-branch-name`.
28+
4. **Make your changes.**
29+
5. **Run the tests** to make sure everything is still working: `composer test`.
30+
6. **Run the code formatter** to ensure your code follows our style guide: `composer format`.
31+
7. **Run the static analyzer** to check for potential bugs: `composer analyse`.
32+
8. **Commit your changes** with a clear and descriptive commit message.
33+
9. **Push your changes** to your fork: `git push origin your-branch-name`.
34+
10. **Open a pull request** to the `master` branch of the main repository.
2635

27-
### Working with the OTE MVP
36+
## Coding Standards
2837

29-
The OTE MVP is built with Laravel. Here are some key things to know when working with the codebase:
38+
This project uses [Laravel Pint](https://laravel.com/docs/pint) to enforce a consistent coding style. Before you commit your changes, please run the code formatter:
3039

31-
* **Models:** The Eloquent models are located in `app/Models`.
32-
* **Views:** The Blade views are located in `resources/views`.
33-
* **Controllers:** The HTTP controllers are located in `app/Http/Controllers`.
34-
* **CLI Commands:** The Artisan commands are located in `app/Console/Commands`.
35-
* **Routes:** The web routes are defined in `routes/web.php`.
36-
* **Tests:** The tests are located in the `tests` directory.
40+
```bash
41+
composer format
42+
```
3743

38-
When adding new features, please try to follow the existing code style and structure.
44+
## Running Tests
3945

40-
Thank you for your contributions!
46+
This project uses [Pest](https://pestphp.com/) for testing. To run the test suite, use the following command:
47+
48+
```bash
49+
composer test
50+
```
51+
52+
## Static Analysis
53+
54+
This project uses [PHPStan](https://phpstan.org/) with the [Larastan](https://github.com/larastan/larastan) extension for static analysis. To run the static analyzer, use the following command:
55+
56+
```bash
57+
composer analyse
58+
```
59+
60+
Thank you for your contribution!

README.md

Lines changed: 70 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ To get started with the development of OTE v2, you will need to have PHP and Com
3636

3737
For information on how to run the test suite, please see the [Testing Documentation](tests/README.md).
3838

39+
### Git Hooks
40+
41+
This project includes a pre-commit hook that runs `pint` and `phpstan` to ensure code quality before each commit. To use it, you need to create a symbolic link from `.git/hooks/pre-commit` to the script.
42+
43+
From the root of the project, run the following command:
44+
45+
```bash
46+
ln -s ../../bin/pre-commit.sh .git/hooks/pre-commit
47+
```
48+
3949
### Deployment
4050

4151
This project is configured for automated deployment on [Render](https://render.com/). For detailed instructions on how to deploy your own instance, please see the [Render Deployment Guide](docs/RENDER.md).
@@ -50,29 +60,20 @@ The following is a summary of the planned features for OTE v2. For a more detail
5060
* **Editor Features:** Word and word pair management, imports.
5161
* **Admin Features:** Language and user management.
5262

53-
## OTE v1
63+
## Known Issues
5464

55-
The previous version of OTE is still available.
65+
### Laravel Dusk
5666

57-
* The last stable release is **OTE v0.9.9**: [v0.9.9 branch](https://github.com/attogram/ote/tree/v0.9.9)
58-
* OTE Version 1 was a test with the Attogram Framework: [v1 branch](https://github.com/attogram/ote/tree/v1)
67+
At the time of writing, there are known issues with running Laravel Dusk in some development environments. The test runner (Pest) seems to have a conflict with how Dusk's test cases are discovered, which can lead to errors. Additionally, there can be issues with the ChromeDriver and Chrome binary setup.
5968
60-
### Known Installations of OTE v1
69+
For these reasons, browser testing with Dusk has been temporarily disabled.
6170
62-
* <http://ote.2meta.com/>
63-
* <http://indo-european.info/dictionary-translator/>
64-
* <http://indo-european.info/translator-dictionary/>
65-
* <http://indogermanisch.org/woerterbuch-uebersetzer/>
66-
* <http://www.elas.sk/lehota/slovnik/>
67-
* <http://fenry.lescigales.org/ryzom/otr/>
68-
* <http://indo-european.info/pokorny-etymology-dictionary/>
69-
* <http://dictionar.poezie.ro/>
71+
## OTE v1
7072
71-
### Related Projects
73+
The previous version of OTE is still available.
7274
73-
* <https://github.com/elexis-eu/lexonomy>
74-
* <http://www.omegawiki.org/>
75-
* <https://github.com/glosswordteam/Glossword>
75+
* The last stable release is **OTE v0.9.9**: [v0.9.9 branch](https://github.com/attogram/ote/tree/v0.9.9)
76+
* OTE Version 1 was a test with the Attogram Framework: [v1 branch](https://github.com/attogram/ote/tree/v1)
7677
7778
## Citations
7879
@@ -88,6 +89,45 @@ Multilingual Online Resources for Minority Languages of a Campus Community
8889
8990
The Open Translation Engine is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
9091
92+
## Development with GitHub Codespaces
93+
94+
This repository is configured to use [GitHub Codespaces](https://github.com/features/codespaces) for a cloud-based development environment.
95+
96+
### Getting Started
97+
98+
1. Click the "Code" button on the repository's main page.
99+
2. Select the "Codespaces" tab.
100+
3. Click "Create codespace on main".
101+
102+
GitHub will then create a new Codespace and set up the environment for you automatically. This includes:
103+
- Building the Docker containers for the application, database, and Redis.
104+
- Installing all Composer dependencies.
105+
- Creating the `.env` file.
106+
- Generating the application key.
107+
- Running database migrations and seeding it with sample data.
108+
109+
### Usage
110+
111+
- **Accessing the application:**
112+
Once the Codespace is ready, it will automatically forward the application's port (8000). To start the web server, run the following command in the terminal:
113+
```bash
114+
php artisan serve --host=0.0.0.0 --port=8000
115+
```
116+
You can then access the application from the "Ports" tab in the VS Code editor or by clicking the notification that appears.
117+
118+
- **Running Artisan commands:**
119+
You can run `artisan` commands directly in the VS Code terminal:
120+
```bash
121+
php artisan route:list
122+
```
123+
124+
- **Running NPM commands:**
125+
You can also run `npm` commands in the terminal:
126+
```bash
127+
npm install
128+
npm run dev
129+
```
130+
91131
## Development Environment with Docker
92132
93133
This project includes a Docker-based development environment that allows you to run the application and its dependencies in isolated containers.
@@ -179,37 +219,19 @@ This project includes a Docker-based development environment that allows you to
179219
docker compose -f compose.dev.yml down
180220
```
181221
182-
## Development with GitHub Codespaces
183-
184-
This repository is configured to use [GitHub Codespaces](https://github.com/features/codespaces) for a cloud-based development environment.
185-
186-
### Getting Started
187-
188-
1. Click the "Code" button on the repository's main page.
189-
2. Select the "Codespaces" tab.
190-
3. Click "Create codespace on main".
191-
192-
GitHub will then create a new Codespace and set up the environment for you automatically. This includes:
193-
- Building the Docker containers for the application, database, and Redis.
194-
- Installing all Composer dependencies.
195-
- Creating the `.env` file.
196-
- Generating the application key.
197-
- Running database migrations and seeding it with sample data.
198-
199-
### Usage
222+
### Related Projects
200223
201-
- **Accessing the application:**
202-
Once the Codespace is ready, it will automatically forward the application's port (8000). You can access the application from the "Ports" tab in the VS Code editor or by clicking the notification that appears.
224+
* <https://github.com/elexis-eu/lexonomy>
225+
* <http://www.omegawiki.org/>
226+
* <https://github.com/glosswordteam/Glossword>
203227
204-
- **Running Artisan commands:**
205-
You can run `artisan` commands directly in the VS Code terminal:
206-
```bash
207-
php artisan route:list
208-
```
228+
### Known Installations of OTE v1
209229
210-
- **Running NPM commands:**
211-
You can also run `npm` commands in the terminal:
212-
```bash
213-
npm install
214-
npm run dev
215-
```
230+
* <http://ote.2meta.com/>
231+
* <http://indo-european.info/dictionary-translator/>
232+
* <http://indo-european.info/translator-dictionary/>
233+
* <http://indogermanisch.org/woerterbuch-uebersetzer/>
234+
* <http://www.elas.sk/lehota/slovnik/>
235+
* <http://fenry.lescigales.org/ryzom/otr/>
236+
* <http://indo-european.info/pokorny-etymology-dictionary/>
237+
* <http://dictionar.poezie.ro/>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\Attribute;
6+
use Illuminate\Console\Command;
7+
8+
class DeleteAttribute extends Command
9+
{
10+
protected $signature = 'ote:delete-attribute {id : The ID of the attribute to delete}';
11+
12+
protected $description = 'Deletes an attribute.';
13+
14+
public function handle()
15+
{
16+
$id = $this->argument('id');
17+
$attribute = Attribute::find($id);
18+
19+
if (!$attribute) {
20+
$this->error("Attribute with ID '{$id}' not found.");
21+
return 1;
22+
}
23+
24+
$attribute->delete();
25+
26+
$this->info("Attribute with ID '{$id}' has been deleted.");
27+
}
28+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\LexicalEntry;
6+
use Illuminate\Console\Command;
7+
8+
class DeleteEntry extends Command
9+
{
10+
protected $signature = 'ote:delete-entry {id : The ID of the lexical entry to delete}';
11+
12+
protected $description = 'Deletes a lexical entry and its associated attributes and links.';
13+
14+
public function handle()
15+
{
16+
$id = $this->argument('id');
17+
$entry = LexicalEntry::find($id);
18+
19+
if (!$entry) {
20+
$this->error("Lexical entry with ID '{$id}' not found.");
21+
return 1;
22+
}
23+
24+
// Manually delete related attributes and links
25+
$entry->attributes()->delete();
26+
$entry->links()->delete();
27+
$entry->linkedFrom()->delete();
28+
29+
$entry->delete();
30+
31+
$this->info("Lexical entry with ID '{$id}' has been deleted.");
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\Language;
6+
use Illuminate\Console\Command;
7+
8+
class DeleteLanguage extends Command
9+
{
10+
protected $signature = 'ote:delete-language {language : The code of the language to delete}';
11+
12+
protected $description = 'Deletes a language and its associated lexical entries.';
13+
14+
public function handle()
15+
{
16+
$languageCode = $this->argument('language');
17+
$language = Language::where('code', $languageCode)->first();
18+
19+
if (!$language) {
20+
$this->error("Language '{$languageCode}' not found.");
21+
return 1;
22+
}
23+
24+
// Manually delete related lexical entries because of potential model events.
25+
foreach ($language->lexicalEntries as $entry) {
26+
$entry->delete();
27+
}
28+
29+
$language->delete();
30+
31+
$this->info("Language '{$languageCode}' and its associated lexical entries have been deleted.");
32+
}
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\Link;
6+
use Illuminate\Console\Command;
7+
8+
class DeleteLink extends Command
9+
{
10+
protected $signature = 'ote:delete-link {id : The ID of the link to delete}';
11+
12+
protected $description = 'Deletes a link.';
13+
14+
public function handle()
15+
{
16+
$id = $this->argument('id');
17+
$link = Link::find($id);
18+
19+
if (!$link) {
20+
$this->error("Link with ID '{$id}' not found.");
21+
return 1;
22+
}
23+
24+
$link->delete();
25+
26+
$this->info("Link with ID '{$id}' has been deleted.");
27+
}
28+
}

0 commit comments

Comments
 (0)