@fishawack/lab-env 4.44.1 → 4.45.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/_Ai/laravel-12.md +483 -34
- package/_Ai/python-3.md +42 -0
- package/cli.js +89 -63
- package/commands/connect.js +1 -1
- package/commands/create/cmds/dekey.js +3 -1
- package/commands/create/cmds/deprovision.js +3 -1
- package/commands/create/cmds/key.js +3 -1
- package/commands/create/cmds/provision.js +3 -1
- package/commands/create/libs/vars.js +1 -1
- package/commands/create/services/aws/elasticbeanstalk.js +2 -2
- package/commands/create/services/aws/iam.js +8 -0
- package/commands/create/services/aws/index.js +1 -0
- package/commands/execute.js +1 -1
- package/commands/nuke.js +6 -4
- package/commands/pip.js +13 -0
- package/commands/python.js +13 -0
- package/commands/setup.js +5 -0
- package/commands/start.js +6 -0
- package/eslint.config.js +2 -0
- package/globals.js +27 -2
- package/package.json +1 -1
- package/python/0/docker-compose.yml +24 -0
- package/stylelint.config.js +2 -0
- package/core/1/CHANGELOG.md +0 -136
- package/core/1/Dockerfile +0 -113
- package/core/1/README.md +0 -9
- package/core/1/bitbucket-pipelines.yml +0 -82
- package/core/1/docker-compose.yml +0 -37
- package/core/1/entrypoint.sh +0 -24
- package/core/1/package.json +0 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### 4.45.0-beta.1 (2025-09-01)
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* added a manage users permission ([e59b21a](https://bitbucket.org/fishawackdigital/lab-env/commits/e59b21a3c3d307aae3430cce676d8f20ed936525))
|
|
8
|
+
* added besins client ([58bcc77](https://bitbucket.org/fishawackdigital/lab-env/commits/58bcc771fe28029e92e63be315292605974c747a))
|
|
9
|
+
* added custom python setup and start commands ([6ca192f](https://bitbucket.org/fishawackdigital/lab-env/commits/6ca192f92bf1044b52aaa1e890a13be68d9cb366))
|
|
10
|
+
* added devops preset ([46f43c5](https://bitbucket.org/fishawackdigital/lab-env/commits/46f43c5f7c0648112edb3ff20439626fd6a69077))
|
|
11
|
+
* added devops specific commands ([21daf7a](https://bitbucket.org/fishawackdigital/lab-env/commits/21daf7a8dfb9cde0ed88b2a943c6753ef1ea003f))
|
|
12
|
+
* added python instructions file ([4ba1c77](https://bitbucket.org/fishawackdigital/lab-env/commits/4ba1c7717e8e41414758d1e77bab6fc891553763))
|
|
13
|
+
* copy python ai files ([def8212](https://bitbucket.org/fishawackdigital/lab-env/commits/def8212f7151a6714a76e5096c7c41c1cf55908f))
|
|
14
|
+
* copy the lab-env ai file into projects ([c217274](https://bitbucket.org/fishawackdigital/lab-env/commits/c2172745ebef906536d12347c051c4e3d38f663d))
|
|
15
|
+
* improved laravel ai docs ([076bd4d](https://bitbucket.org/fishawackdigital/lab-env/commits/076bd4d6d99ad58ca68b117b8d0425e3ada72cb3))
|
|
16
|
+
* split lab-env into standalone ai file ([4f84fd9](https://bitbucket.org/fishawackdigital/lab-env/commits/4f84fd9999e571b67d313511f00f5bee310ac24b))
|
|
17
|
+
* support python builds ([10f9929](https://bitbucket.org/fishawackdigital/lab-env/commits/10f99291306f060e720ad2e2ccf536ecda12a53c))
|
|
18
|
+
* two new commands for pip and python ([658191a](https://bitbucket.org/fishawackdigital/lab-env/commits/658191a4dfeba7459d4513a875b9511fb5f1e5ee))
|
|
19
|
+
* updates to lab-env config ([de73808](https://bitbucket.org/fishawackdigital/lab-env/commits/de73808cf13283ad469161c27937671de14ffcdb))
|
|
20
|
+
|
|
21
|
+
#### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* added apply to to lab env ai file ([e82f875](https://bitbucket.org/fishawackdigital/lab-env/commits/e82f87543f0cc3add465b414b393a50b595e95c1))
|
|
24
|
+
* added more context around query binding ([4cfd427](https://bitbucket.org/fishawackdigital/lab-env/commits/4cfd42737fa9b19d5b24e28e9219bbae629c5b32))
|
|
25
|
+
* dont attempt to remove volumes if there aren't any ([ac9f621](https://bitbucket.org/fishawackdigital/lab-env/commits/ac9f62133f47b1e4971524fc75e8ae94ba32d4ba))
|
|
26
|
+
* fixed no cache flag ([d1f3f9a](https://bitbucket.org/fishawackdigital/lab-env/commits/d1f3f9a329177f2431be802897d37bfdf3df5b1e))
|
|
27
|
+
* ignore .venv from linting checks ([e49fa69](https://bitbucket.org/fishawackdigital/lab-env/commits/e49fa698397ba2287def174ad3b2a5608b7a393b))
|
|
28
|
+
* support no core in python projects ([2882070](https://bitbucket.org/fishawackdigital/lab-env/commits/2882070c34546daf1d261f708a63687dcc303dfc))
|
|
29
|
+
* support python in execute command ([619deea](https://bitbucket.org/fishawackdigital/lab-env/commits/619deea45eac08d41076b70c505fdaf043e5c7c1))
|
|
30
|
+
* switch connect default to python for those projects ([d481960](https://bitbucket.org/fishawackdigital/lab-env/commits/d481960f1a836f5841dcf79ec5f90819eacae212))
|
|
31
|
+
* use php 8.2 for new php environments ([d2a180e](https://bitbucket.org/fishawackdigital/lab-env/commits/d2a180ebcbf679d49b598f22b6587b3e28327b2a))
|
|
32
|
+
|
|
3
33
|
### 4.44.1 (2025-08-18)
|
|
4
34
|
|
|
5
35
|
#### Bug Fixes
|
package/_Ai/laravel-12.md
CHANGED
|
@@ -2,19 +2,477 @@
|
|
|
2
2
|
applyTo: "app/**/*,bootstrap/**/*,config/**/*,database/**/*,resources/**/*,routes/**/*,tests/**/*,composer.json,phpunit.xml"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
# GitHub Copilot Instructions for Laravel
|
|
5
|
+
# GitHub Copilot Instructions for Laravel 12 Project
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Laravel Model Structure & Architecture
|
|
8
8
|
|
|
9
|
-
This is a Laravel application
|
|
9
|
+
This is a Laravel 12 application using a comprehensive model architecture. When creating new models, follow this complete structure pattern based on existing codebase conventions.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
### Complete Model Creation Command
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
```bash
|
|
14
|
+
# Create all standard files for a model (Model, Factory, Migration, Seeder, Controller, Policy)
|
|
15
|
+
fw artisan make:model Post -a --api
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Additional Files Required Per Model
|
|
19
|
+
|
|
20
|
+
After running the base command, create these additional files:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Create Request (combines store/update requests)
|
|
24
|
+
fw artisan make:request PostRequest
|
|
25
|
+
|
|
26
|
+
# Create Observer
|
|
27
|
+
fw artisan make:observer PostObserver -m Post
|
|
28
|
+
|
|
29
|
+
# Create Resource
|
|
30
|
+
fw artisan make:resource PostResource
|
|
31
|
+
|
|
32
|
+
# Create Query (custom class for query building)
|
|
33
|
+
fw artisan make:class Http/Queries/PostQuery
|
|
34
|
+
|
|
35
|
+
# Create Test
|
|
36
|
+
fw artisan make:test PostTest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Model Architecture Patterns
|
|
40
|
+
|
|
41
|
+
### 1. Model Structure
|
|
42
|
+
|
|
43
|
+
Models should follow this pattern:
|
|
44
|
+
|
|
45
|
+
```php
|
|
46
|
+
<?php
|
|
47
|
+
|
|
48
|
+
namespace App\Models;
|
|
49
|
+
|
|
50
|
+
use App\Http\Queries\PostQuery;
|
|
51
|
+
use App\Observers\PostObserver;
|
|
52
|
+
use App\Traits\QueryBuilderBindable;
|
|
53
|
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
54
|
+
use Illuminate\Database\Eloquent\Model;
|
|
55
|
+
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
56
|
+
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
|
57
|
+
|
|
58
|
+
#[ObservedBy([PostObserver::class])]
|
|
59
|
+
class Post extends Model {
|
|
60
|
+
use HasFactory, QueryBuilderBindable, SoftDeletes;
|
|
61
|
+
|
|
62
|
+
public static $queryClass = PostQuery::class;
|
|
63
|
+
|
|
64
|
+
protected $fillable = [
|
|
65
|
+
// Define fillable attributes
|
|
66
|
+
"title",
|
|
67
|
+
"content",
|
|
68
|
+
"status",
|
|
69
|
+
"created_by",
|
|
70
|
+
"updated_by",
|
|
71
|
+
"deleted_by"
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
protected $casts = [
|
|
75
|
+
// Cast enums and other types
|
|
76
|
+
"status" => PostStatusEnum::class
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Key conventions:**
|
|
82
|
+
|
|
83
|
+
- Use `#[ObservedBy([ModelObserver::class])]` attribute for observer registration
|
|
84
|
+
- Always include `QueryBuilderBindable` trait
|
|
85
|
+
- Include `SoftDeletes` for most models
|
|
86
|
+
- Set `public static $queryClass` property
|
|
87
|
+
- Use enum casting where applicable
|
|
88
|
+
- Include author tracking fields (`created_by`, `updated_by`, `deleted_by`)
|
|
89
|
+
|
|
90
|
+
The QueryBuilderBindable trait should resolve route model binding for controller endpoints and contain the following code
|
|
91
|
+
|
|
92
|
+
```php
|
|
93
|
+
<?php
|
|
94
|
+
|
|
95
|
+
namespace App\Traits;
|
|
96
|
+
|
|
97
|
+
trait QueryBuilderBindable {
|
|
98
|
+
public function resolveRouteBinding($value, $field = null) {
|
|
99
|
+
return (new $this::$queryClass())
|
|
100
|
+
->where($field ?? $this->getRouteKeyName(), $value)
|
|
101
|
+
->first();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This results in less eager loading of variables that are expected from the api endpoints as it allows the api request itself to define which models it wants to load via query params
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
/api/posts/1?include=comments
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 2. Request Structure
|
|
113
|
+
|
|
114
|
+
Combine store/update requests into single file:
|
|
115
|
+
|
|
116
|
+
```php
|
|
117
|
+
<?php
|
|
118
|
+
|
|
119
|
+
namespace App\Http\Requests;
|
|
120
|
+
|
|
121
|
+
use App\Traits\HandlesPatchRequests;
|
|
122
|
+
use Illuminate\Foundation\Http\FormRequest;
|
|
123
|
+
use Illuminate\Validation\Rule;
|
|
124
|
+
|
|
125
|
+
class PostRequest extends FormRequest {
|
|
126
|
+
use HandlesPatchRequests;
|
|
127
|
+
|
|
128
|
+
public function authorize(): bool {
|
|
129
|
+
return true; // Authorization handled by Policy
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public function rules(): array {
|
|
133
|
+
$arr = [
|
|
134
|
+
"title" => "required|string|max:255",
|
|
135
|
+
"content" => "required|string",
|
|
136
|
+
"status" => [Rule::enum(PostStatusEnum::class)]
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
// Handle PATCH requests (make fields optional)
|
|
140
|
+
if ($this->isMethod("patch")) {
|
|
141
|
+
$arr = $this->handlePatchRequest($arr);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return $arr;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Key conventions:**
|
|
150
|
+
|
|
151
|
+
- Extend `FormRequest` directly (not BaseFormRequest)
|
|
152
|
+
- Include `HandlesPatchRequests` trait
|
|
153
|
+
- Set `authorize()` to `true` (policies handle authorization)
|
|
154
|
+
- Use `handlePatchRequest()` for PATCH method validation
|
|
155
|
+
- Use `Rule::enum()` for enum validation
|
|
156
|
+
|
|
157
|
+
### 3. Controller Structure
|
|
158
|
+
|
|
159
|
+
```php
|
|
160
|
+
<?php
|
|
161
|
+
|
|
162
|
+
namespace App\Http\Controllers;
|
|
163
|
+
|
|
164
|
+
use App\Http\Requests\PostRequest;
|
|
165
|
+
use App\Http\Resources\PostResource;
|
|
166
|
+
use App\Models\Post;
|
|
167
|
+
|
|
168
|
+
class PostController extends Controller {
|
|
169
|
+
public function __construct() {
|
|
170
|
+
$this->authorizeResource(Post::class, "post");
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public function index() {
|
|
174
|
+
return PostResource::collection(
|
|
175
|
+
(new Post::$queryClass())
|
|
176
|
+
->paginate(request("per_page", 10))
|
|
177
|
+
->appends(request()->query())
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
public function store(PostRequest $request) {
|
|
182
|
+
$post = Post::create($request->validated());
|
|
183
|
+
|
|
184
|
+
return (new PostResource($post))->response()->setStatusCode(201);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
public function show(Post $post) {
|
|
188
|
+
return new PostResource($post);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
public function update(PostRequest $request, Post $post) {
|
|
192
|
+
$post->update($request->validated());
|
|
193
|
+
|
|
194
|
+
return new PostResource($post);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public function destroy(Post $post) {
|
|
198
|
+
$post->delete();
|
|
199
|
+
|
|
200
|
+
return response()->json(null, 204);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Key conventions:**
|
|
206
|
+
|
|
207
|
+
- Use `authorizeResource()` in constructor
|
|
208
|
+
- Use model's `$queryClass` for queries
|
|
209
|
+
- Use `request('per_page', 10)` for pagination
|
|
210
|
+
- Append query parameters with `appends(request()->query())`
|
|
211
|
+
- Return 201 status for store, 204 for destroy
|
|
212
|
+
- Use resource classes for all responses
|
|
213
|
+
|
|
214
|
+
### 4. Resource Structure
|
|
215
|
+
|
|
216
|
+
```php
|
|
217
|
+
<?php
|
|
16
218
|
|
|
17
|
-
|
|
219
|
+
namespace App\Http\Resources;
|
|
220
|
+
|
|
221
|
+
use Illuminate\Http\Request;
|
|
222
|
+
use Illuminate\Http\Resources\Json\JsonResource;
|
|
223
|
+
|
|
224
|
+
class PostResource extends JsonResource {
|
|
225
|
+
public function toArray(Request $request): array {
|
|
226
|
+
return [
|
|
227
|
+
"id" => $this->id,
|
|
228
|
+
"title" => $this->title,
|
|
229
|
+
"content" => $this->content,
|
|
230
|
+
"status" => new EnumResource($this->status),
|
|
231
|
+
"created_at" => $this->created_at,
|
|
232
|
+
"updated_at" => $this->updated_at,
|
|
233
|
+
|
|
234
|
+
// Conditional includes
|
|
235
|
+
"author" => UserResource::collection($this->whenLoaded("author"))
|
|
236
|
+
];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Key conventions:**
|
|
242
|
+
|
|
243
|
+
- Use `EnumResource` for enum fields
|
|
244
|
+
- Use `whenLoaded()` for relationship includes
|
|
245
|
+
- Return raw data without additional wrapping
|
|
246
|
+
|
|
247
|
+
### 5. Query Builder Class
|
|
248
|
+
|
|
249
|
+
```php
|
|
250
|
+
<?php
|
|
251
|
+
|
|
252
|
+
namespace App\Http\Queries;
|
|
253
|
+
|
|
254
|
+
use App\Models\Post;
|
|
255
|
+
use Spatie\QueryBuilder\QueryBuilder;
|
|
256
|
+
use Spatie\QueryBuilder\AllowedFilter;
|
|
257
|
+
use Spatie\QueryBuilder\AllowedInclude;
|
|
258
|
+
|
|
259
|
+
class PostQuery extends QueryBuilder {
|
|
260
|
+
public function __construct($query = null) {
|
|
261
|
+
parent::__construct($query ?: Post::query());
|
|
262
|
+
|
|
263
|
+
$this->defaultSort("id");
|
|
264
|
+
|
|
265
|
+
$this->allowedSorts([
|
|
266
|
+
"id",
|
|
267
|
+
"title",
|
|
268
|
+
"status",
|
|
269
|
+
"created_at",
|
|
270
|
+
"updated_at"
|
|
271
|
+
]);
|
|
272
|
+
|
|
273
|
+
$this->allowedIncludes(["author", "comments"]);
|
|
274
|
+
|
|
275
|
+
$this->allowedFilters([
|
|
276
|
+
AllowedFilter::exact("id"),
|
|
277
|
+
AllowedFilter::exact("status"),
|
|
278
|
+
AllowedFilter::partial("title")
|
|
279
|
+
]);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Key conventions:**
|
|
285
|
+
|
|
286
|
+
- Extend Spatie `QueryBuilder`
|
|
287
|
+
- Set `defaultSort('id')`
|
|
288
|
+
- Define `allowedSorts`, `allowedIncludes`, and `allowedFilters`
|
|
289
|
+
- Use `AllowedFilter::exact()` and `AllowedFilter::partial()` as appropriate
|
|
290
|
+
|
|
291
|
+
### 6. Observer Structure
|
|
292
|
+
|
|
293
|
+
```php
|
|
294
|
+
<?php
|
|
295
|
+
|
|
296
|
+
namespace App\Observers;
|
|
297
|
+
|
|
298
|
+
use App\Models\Post;
|
|
299
|
+
use App\Traits\ObservesAuthorChanges;
|
|
300
|
+
use App\Enums\AuthorChangeEventTypeEnum;
|
|
301
|
+
|
|
302
|
+
class PostObserver {
|
|
303
|
+
use ObservesAuthorChanges;
|
|
304
|
+
|
|
305
|
+
public function created(Post $post): void {
|
|
306
|
+
if (auth()->user()) {
|
|
307
|
+
$this->observeChanges(
|
|
308
|
+
$post,
|
|
309
|
+
auth()->user(),
|
|
310
|
+
AuthorChangeEventTypeEnum::CREATED
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
public function updated(Post $post): void {
|
|
316
|
+
if (auth()->user()) {
|
|
317
|
+
$this->observeChanges(
|
|
318
|
+
$post,
|
|
319
|
+
auth()->user(),
|
|
320
|
+
AuthorChangeEventTypeEnum::UPDATED
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
public function deleted(Post $post): void {
|
|
326
|
+
if (auth()->user()) {
|
|
327
|
+
$this->observeChanges(
|
|
328
|
+
$post,
|
|
329
|
+
auth()->user(),
|
|
330
|
+
AuthorChangeEventTypeEnum::DELETED
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Key conventions:**
|
|
338
|
+
|
|
339
|
+
- Use `ObservesAuthorChanges` trait
|
|
340
|
+
- Check for `auth()->user()` before observing
|
|
341
|
+
- Use `AuthorChangeEventTypeEnum` for event types
|
|
342
|
+
|
|
343
|
+
### 7. Policy Structure
|
|
344
|
+
|
|
345
|
+
```php
|
|
346
|
+
<?php
|
|
347
|
+
|
|
348
|
+
namespace App\Policies;
|
|
349
|
+
|
|
350
|
+
use App\Models\Post;
|
|
351
|
+
use App\Models\User;
|
|
352
|
+
use App\Traits\PerformsSubscriptionChecks;
|
|
353
|
+
|
|
354
|
+
class PostPolicy {
|
|
355
|
+
use PerformsSubscriptionChecks;
|
|
356
|
+
|
|
357
|
+
public function viewAny(User $user): bool {
|
|
358
|
+
return $user->can(PermissionEnum::VIEW_CONTENT->value);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
public function view(User $user, Post $post): bool {
|
|
362
|
+
return $user->can(PermissionEnum::VIEW_CONTENT->value);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
public function create(User $user): bool {
|
|
366
|
+
return $user->can(PermissionEnum::CREATE_CONTENT->value);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
public function update(User $user, Post $post): bool {
|
|
370
|
+
return $user->can(PermissionEnum::EDIT_CONTENT->value);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
public function delete(User $user, Post $post): bool {
|
|
374
|
+
return $user->can(PermissionEnum::DELETE_CONTENT->value);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**Key conventions:**
|
|
380
|
+
|
|
381
|
+
- Use `PerformsSubscriptionChecks` trait where applicable
|
|
382
|
+
- Use permission enums for authorization checks
|
|
383
|
+
- Follow standard policy method names
|
|
384
|
+
|
|
385
|
+
### 8. Test Structure
|
|
386
|
+
|
|
387
|
+
```php
|
|
388
|
+
<?php
|
|
389
|
+
|
|
390
|
+
namespace Tests\Feature;
|
|
391
|
+
|
|
392
|
+
use App\Http\Resources\PostResource;
|
|
393
|
+
use App\Models\Post;
|
|
394
|
+
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
395
|
+
use Tests\Feature\Traits\Resource;
|
|
396
|
+
use Tests\TestCase;
|
|
397
|
+
|
|
398
|
+
class PostTest extends TestCase {
|
|
399
|
+
use RefreshDatabase, Resource;
|
|
400
|
+
|
|
401
|
+
public $endpoint = "/api/posts";
|
|
402
|
+
public $model = Post::class;
|
|
403
|
+
public $resourceClass = PostResource::class;
|
|
404
|
+
|
|
405
|
+
public $invalidInput = [
|
|
406
|
+
"title" => null
|
|
407
|
+
];
|
|
408
|
+
|
|
409
|
+
public $invalidRequiredInput = [
|
|
410
|
+
"title" => null
|
|
411
|
+
];
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**Key conventions:**
|
|
416
|
+
|
|
417
|
+
- Use `RefreshDatabase` and `Resource` traits
|
|
418
|
+
- Set `$endpoint`, `$model`, and `$resourceClass` properties
|
|
419
|
+
- Define `$invalidInput` and `$invalidRequiredInput` arrays
|
|
420
|
+
|
|
421
|
+
### 9. Factory Structure
|
|
422
|
+
|
|
423
|
+
```php
|
|
424
|
+
<?php
|
|
425
|
+
|
|
426
|
+
namespace Database\Factories;
|
|
427
|
+
|
|
428
|
+
use App\Enums\PostStatusEnum;
|
|
429
|
+
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
430
|
+
|
|
431
|
+
class PostFactory extends Factory {
|
|
432
|
+
public function definition(): array {
|
|
433
|
+
return [
|
|
434
|
+
"title" => fake()->sentence(),
|
|
435
|
+
"content" => fake()->paragraphs(3, true),
|
|
436
|
+
"status" => $this->faker->randomElement(PostStatusEnum::cases())
|
|
437
|
+
];
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
**Key conventions:**
|
|
443
|
+
|
|
444
|
+
- Use `fake()` helper for data generation
|
|
445
|
+
- Use `randomElement()` with enum cases for enum fields
|
|
446
|
+
- Keep factories simple and focused
|
|
447
|
+
|
|
448
|
+
## Route Registration
|
|
449
|
+
|
|
450
|
+
Add API resource routes in `routes/api.php`:
|
|
451
|
+
|
|
452
|
+
```php
|
|
453
|
+
Route::middleware(["auth:sanctum"])->group(function () {
|
|
454
|
+
Route::apiResource("posts", \App\Http\Controllers\PostController::class);
|
|
455
|
+
});
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
## Migration Best Practices
|
|
459
|
+
|
|
460
|
+
- Never access models in migrations
|
|
461
|
+
- Use DB facade directly for data manipulation
|
|
462
|
+
- Follow standard Laravel migration conventions
|
|
463
|
+
- Use descriptive migration names
|
|
464
|
+
|
|
465
|
+
## Critical Notes
|
|
466
|
+
|
|
467
|
+
- **All Laravel/PHP operations must use `fw` prefix** (e.g., `fw artisan`, `fw composer`)
|
|
468
|
+
- **Model names should be Capital case and singular** (e.g., Post, Comment, Media)
|
|
469
|
+
- **Observers are registered using attributes, not service providers**
|
|
470
|
+
- **All API endpoints should be protected with `auth:sanctum` middleware**
|
|
471
|
+
- **Policies handle authorization, not request authorize() methods**
|
|
472
|
+
- **Enums should be created when needed, not by default**
|
|
473
|
+
- **Seeders are required for all models**
|
|
474
|
+
|
|
475
|
+
## Laravel Command Patterns
|
|
18
476
|
|
|
19
477
|
### Composer Operations
|
|
20
478
|
|
|
@@ -107,24 +565,24 @@ fw artisan tinker
|
|
|
107
565
|
- **Environment**: Use [`.env.example`](.env.example) as reference for environment variables
|
|
108
566
|
- **Frontend**: Resources in [`resources/`](resources/) directory with build system using npm scripts
|
|
109
567
|
|
|
110
|
-
## Environment
|
|
568
|
+
## Laravel Environment Configuration
|
|
111
569
|
|
|
112
|
-
Reference the [`.env.example`](.env.example) file for
|
|
570
|
+
Reference the [`.env.example`](.env.example) file for Laravel-specific environment variables:
|
|
113
571
|
|
|
114
572
|
- Database connection uses `mysql` service
|
|
115
573
|
- Redis connection uses `redis` service
|
|
116
574
|
- Mail testing uses `mailhog` service
|
|
117
575
|
- App URL defaults to `http://localhost:3000`
|
|
118
576
|
|
|
119
|
-
## Build System
|
|
577
|
+
## Laravel Build System
|
|
120
578
|
|
|
121
579
|
- Frontend assets managed via npm scripts defined in [`package.json`](package.json)
|
|
122
|
-
- Uses `@fishawack/core` build system
|
|
123
|
-
- Run `npm run start` for development
|
|
124
|
-
- Run `npm run production` for production builds
|
|
125
|
-
-
|
|
580
|
+
- Uses `@fishawack/core` build system optimized for Laravel
|
|
581
|
+
- Run `fw npm run start` for development
|
|
582
|
+
- Run `fw npm run production` for production builds
|
|
583
|
+
- Public directory gitignored - assets copied from resources/ during build
|
|
126
584
|
|
|
127
|
-
##
|
|
585
|
+
## Laravel Configuration Notes
|
|
128
586
|
|
|
129
587
|
- Application uses Laravel 12
|
|
130
588
|
- PHP 8+ requirement
|
|
@@ -133,30 +591,21 @@ Reference the [`.env.example`](.env.example) file for available environment vari
|
|
|
133
591
|
- Queue: Sync driver (no queue worker needed for development)
|
|
134
592
|
- Storage: Local disk with public disk for uploads
|
|
135
593
|
|
|
136
|
-
##
|
|
137
|
-
|
|
138
|
-
1. Always assume containerized environment
|
|
139
|
-
2. Prefix ALL PHP/Composer/Artisan commands with `fw`
|
|
140
|
-
3. Reference existing configuration patterns from the [`config/`](config/) directory
|
|
141
|
-
4. Follow Laravel conventions and use existing service providers
|
|
142
|
-
5. Consider the build system when suggesting frontend changes
|
|
143
|
-
|
|
144
|
-
## Testing Guidelines
|
|
594
|
+
## Laravel Testing Guidelines
|
|
145
595
|
|
|
146
596
|
- Unit tests go in [`tests/Unit/`](tests/Unit/)
|
|
147
597
|
- Feature tests go in [`tests/Feature/`](tests/Feature/)
|
|
148
598
|
- Use the existing [`phpunit.xml`](phpunit.xml) configuration
|
|
149
599
|
- Run tests via `fw artisan test`
|
|
150
600
|
|
|
151
|
-
##
|
|
152
|
-
|
|
153
|
-
The `fw` command is our container orchestration manager that:
|
|
601
|
+
## Laravel Code Suggestions
|
|
154
602
|
|
|
155
|
-
|
|
156
|
-
- Provides direct access to PHP, Composer, and Artisan within containers
|
|
157
|
-
- Handles database connections and other services
|
|
158
|
-
- Should be used for ALL Laravel/PHP related commands
|
|
603
|
+
When suggesting code changes:
|
|
159
604
|
|
|
160
|
-
|
|
605
|
+
1. Always use containerized commands with `fw` prefix
|
|
606
|
+
2. Reference existing configuration patterns from the [`config/`](config/) directory
|
|
607
|
+
3. Follow Laravel 12 conventions and use existing service providers
|
|
608
|
+
4. Consider the build system when suggesting frontend changes
|
|
609
|
+
5. Use Laravel's built-in features and helpers where possible
|
|
161
610
|
|
|
162
|
-
|
|
611
|
+
**CRITICAL**: All Laravel/PHP operations must use the `fw` container orchestration manager. Never suggest direct `php`, `composer`, or `artisan` commands.
|
package/_Ai/python-3.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "src/**/*"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# GitHub Copilot Instructions for Python Project
|
|
6
|
+
|
|
7
|
+
## Project Overview
|
|
8
|
+
|
|
9
|
+
This is a Python application that runs entirely in the host machine. All Python and pip operations must be executed within the appropriate environment using `venv`, `pip` and `python` for the python executable.
|
|
10
|
+
|
|
11
|
+
## Project Management
|
|
12
|
+
|
|
13
|
+
- The codebase follows a standard Python project structure.
|
|
14
|
+
- Virtual environments are used to manage dependencies.
|
|
15
|
+
- Always run python and pip from the virtual environment directly (`./venv/bin/python` and `./venv/bin/pip`)
|
|
16
|
+
- The project runs on Python 3.13 or higher.
|
|
17
|
+
- The project must always use the `python-dotenv` package to load environment variables from a `.env` file.
|
|
18
|
+
- All dependencies are listed in the `requirements.txt` file.
|
|
19
|
+
- The project uses FastAPI and Uvicorn for the web server. Upon running the project, it will be accessible at `http://localhost:3000` and it'll keep running as long as the process is active. For easier development, pipe the output to a log file.
|
|
20
|
+
- The project must always try to stay stateless and handle requests with in-memory processing whenever possible.
|
|
21
|
+
- The project must always fail gracefully and return appropriate error messages.
|
|
22
|
+
|
|
23
|
+
## Common Command Patterns
|
|
24
|
+
|
|
25
|
+
### Run Project
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Update dependencies
|
|
29
|
+
pip install -r ./src/requirements.txt
|
|
30
|
+
|
|
31
|
+
# Add new package
|
|
32
|
+
pip install package/name
|
|
33
|
+
|
|
34
|
+
# Run project
|
|
35
|
+
python ./src/main.py
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Project Structure Context
|
|
39
|
+
|
|
40
|
+
- **Main application**: The main entry point is `./src/main.py`
|
|
41
|
+
- **Routes**: API routes are defined in `./src/routes/*.py`
|
|
42
|
+
- **Connectors**: LLM Connectors are defined in `./src/connectors/*.py`
|