@anu8151/adonisjs-blueprint 0.2.0 → 0.3.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/build/configure.js +4 -1
- package/build/index.js +2 -2
- package/build/src/commands/build.js +1 -1
- package/build/src/commands/main.js +1 -1
- package/build/src/commands/stubs.js +1 -1
- package/build/src/generators/base_generator.js +1 -1
- package/build/src/generators/controller_generator.js +1 -1
- package/build/src/parser.js +1 -1
- package/build/stubs/main.d.ts +1 -1
- package/build/stubs/main.js +9 -0
- package/package.json +3 -1
- package/stubs/README.md +6 -0
- package/stubs/config.stub +32 -0
- package/stubs/main.ts +7 -0
- package/stubs/make/controller/main.stub +47 -0
- package/stubs/make/enum/main.stub +10 -0
- package/stubs/make/event/main.stub +12 -0
- package/stubs/make/factory/main.stub +25 -0
- package/stubs/make/job/main.stub +12 -0
- package/stubs/make/mail/main.stub +23 -0
- package/stubs/make/middleware/main.stub +16 -0
- package/stubs/make/migration/main.stub +25 -0
- package/stubs/make/model/main.stub +19 -0
- package/stubs/make/notification/main.stub +28 -0
- package/stubs/make/policy/main.stub +17 -0
- package/stubs/make/seeder/main.stub +21 -0
- package/stubs/make/service/main.stub +8 -0
- package/stubs/make/test/controller.stub +23 -0
- package/stubs/make/validator/main.stub +22 -0
- package/stubs/make/view/edge.stub +65 -0
- package/stubs/make/view/react.stub +57 -0
- package/stubs/make/view/svelte.stub +67 -0
- package/stubs/make/view/vue.stub +74 -0
- package/build/main-1fZp_M_R.js +0 -8
- package/build/{init-TjAcOVVP.js → init-JJYCiAqQ.js} +0 -0
- package/build/{parser-DJB5DEck.js → parser-CmOj1YQa.js} +1 -1
- /package/build/{statements_registry-DzyxAiKP.js → statements_registry-DqPUH7B3.js} +0 -0
package/build/configure.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stubsRoot } from "./stubs/main.js";
|
|
2
2
|
//#region configure.ts
|
|
3
3
|
async function configure(command) {
|
|
4
|
+
/**
|
|
5
|
+
* Publish config file
|
|
6
|
+
*/
|
|
4
7
|
await (await command.createCodemods()).makeUsingStub(stubsRoot, "config.stub", {});
|
|
5
8
|
}
|
|
6
9
|
//#endregion
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stubsRoot } from "./stubs/main.js";
|
|
2
2
|
import { configure } from "./configure.js";
|
|
3
|
-
import { t as statementsRegistry } from "./statements_registry-
|
|
3
|
+
import { t as statementsRegistry } from "./statements_registry-DqPUH7B3.js";
|
|
4
4
|
//#region index.ts
|
|
5
5
|
function defineConfig(config) {
|
|
6
6
|
return config;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BlueprintParser } from "../../parser-
|
|
1
|
+
import { t as BlueprintParser } from "../../parser-CmOj1YQa.js";
|
|
2
2
|
import { ModelGenerator } from "../generators/model_generator.js";
|
|
3
3
|
import { MigrationGenerator } from "../generators/migration_generator.js";
|
|
4
4
|
import { ControllerGenerator } from "../generators/controller_generator.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as statementsRegistry } from "../../statements_registry-
|
|
1
|
+
import { t as statementsRegistry } from "../../statements_registry-DqPUH7B3.js";
|
|
2
2
|
import { BaseGenerator } from "./base_generator.js";
|
|
3
3
|
import { EventGenerator } from "./event_generator.js";
|
|
4
4
|
import { MailGenerator } from "./mail_generator.js";
|
package/build/src/parser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as BlueprintParser } from "../parser-
|
|
1
|
+
import { t as BlueprintParser } from "../parser-CmOj1YQa.js";
|
|
2
2
|
export { BlueprintParser };
|
package/build/stubs/main.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
//#region stubs/main.ts
|
|
3
|
+
/**
|
|
4
|
+
* Path to the root directory where the stubs are stored. We use
|
|
5
|
+
* this path within commands and the configure hook.
|
|
6
|
+
*/
|
|
7
|
+
const stubsRoot = fileURLToPath(new URL("./", import.meta.url));
|
|
8
|
+
//#endregion
|
|
9
|
+
export { stubsRoot };
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anu8151/adonisjs-blueprint",
|
|
3
3
|
"description": "Blueprint for AdonisJS 7",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"files": [
|
|
10
10
|
"build",
|
|
11
|
+
"stubs",
|
|
11
12
|
"!build/bin",
|
|
12
13
|
"!build/tests"
|
|
13
14
|
],
|
|
@@ -93,6 +94,7 @@
|
|
|
93
94
|
"entry": [
|
|
94
95
|
"./index.ts",
|
|
95
96
|
"./configure.ts",
|
|
97
|
+
"./stubs/main.ts",
|
|
96
98
|
"./src/commands/main.ts",
|
|
97
99
|
"./src/commands/build.ts",
|
|
98
100
|
"./src/commands/erase.ts",
|
package/stubs/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# The stubs directory
|
|
2
|
+
|
|
3
|
+
The `stubs` directory stores all the stubs needed by your package. It could be config files you will publish during the initial setup or stubs you want to use within the scaffolding commands.
|
|
4
|
+
|
|
5
|
+
- Inside the `package.json` file, we have defined a `copy:templates` script that copies the `stubs` folder to the `build` folder.
|
|
6
|
+
- Ensure the `build/stubs` are always published to npm via the `files` array inside the `package.json` file.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.configPath('blueprint.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { defineConfig } from '@anu8151/adonisjs-blueprint'
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
/**
|
|
10
|
+
* Default view framework to use
|
|
11
|
+
* Options: 'edge', 'inertia'
|
|
12
|
+
*/
|
|
13
|
+
viewer: 'edge',
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Default Inertia adapter
|
|
17
|
+
* Options: 'react', 'vue', 'svelte'
|
|
18
|
+
*/
|
|
19
|
+
inertia: {
|
|
20
|
+
adapter: 'react'
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Custom namespaces for generated files
|
|
25
|
+
*/
|
|
26
|
+
namespaces: {
|
|
27
|
+
models: 'app/models',
|
|
28
|
+
controllers: 'app/controllers',
|
|
29
|
+
validators: 'app/validators',
|
|
30
|
+
factories: 'database/factories',
|
|
31
|
+
}
|
|
32
|
+
})
|
package/stubs/main.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('app/controllers', entity.path, entity.name.toLowerCase() + '_controller.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import type { HttpContext } from '@adonisjs/core/http'
|
|
7
|
+
@if(imports.models)
|
|
8
|
+
@each(model in imports.models)
|
|
9
|
+
import {{ model }} from '#models/{{ model.toLowerCase() }}'
|
|
10
|
+
@end
|
|
11
|
+
@end
|
|
12
|
+
@if(imports.validators)
|
|
13
|
+
@each(validator in imports.validators)
|
|
14
|
+
import { {{ validator }} } from '#validators/{{ entity.name.toLowerCase() }}'
|
|
15
|
+
@end
|
|
16
|
+
@end
|
|
17
|
+
@if(imports.events)
|
|
18
|
+
@each(event in imports.events)
|
|
19
|
+
import {{ event }} from '#events/{{ event.toLowerCase() }}'
|
|
20
|
+
@end
|
|
21
|
+
@end
|
|
22
|
+
@if(imports.policies)
|
|
23
|
+
@each(policy in imports.policies)
|
|
24
|
+
import {{ policy }} from '#policies/{{ entity.name.toLowerCase() }}_policy'
|
|
25
|
+
@end
|
|
26
|
+
@end
|
|
27
|
+
@if(imports.services)
|
|
28
|
+
@each(service in imports.services)
|
|
29
|
+
import {{ service.name }} from '#services/{{ service.path }}'
|
|
30
|
+
@end
|
|
31
|
+
@end
|
|
32
|
+
|
|
33
|
+
export default class {{ entity.className }}Controller {
|
|
34
|
+
@if(middleware.length)
|
|
35
|
+
static middleware = [
|
|
36
|
+
@each(item in middleware)
|
|
37
|
+
middleware.{{ item }}(),
|
|
38
|
+
@end
|
|
39
|
+
]
|
|
40
|
+
@end
|
|
41
|
+
|
|
42
|
+
@each(action in actions)
|
|
43
|
+
async {{ action.name }}({ {{ action.context }} }: HttpContext) {
|
|
44
|
+
{{ action.logic }}
|
|
45
|
+
}
|
|
46
|
+
@end
|
|
47
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('app/events', entity.path, entity.name.toLowerCase() + '.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { BaseEvent } from '@adonisjs/core/events'
|
|
7
|
+
|
|
8
|
+
export default class {{ entity.className }} extends BaseEvent {
|
|
9
|
+
constructor(public payload: any) {
|
|
10
|
+
super()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('database/factories', entity.path, entity.name.toLowerCase() + '_factory.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import {{ entity.className }} from '#models/{{ entity.name.toLowerCase() }}'
|
|
7
|
+
import Factory from '@adonisjs/lucid/factories'
|
|
8
|
+
@each(factory in factoryImports)
|
|
9
|
+
import { {{ factory }} } from './{{ factory.replace('Factory', '').toLowerCase() }}_factory'
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
export const {{ entity.className }}Factory = Factory
|
|
13
|
+
.define({{ entity.className }}, ({ faker }) => {
|
|
14
|
+
return {
|
|
15
|
+
@each(attribute in attributes)
|
|
16
|
+
{{ attribute.name }}: faker.{{ attribute.fakerMethod }}(),
|
|
17
|
+
@end
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
@each(rel in relationships)
|
|
21
|
+
@if(rel.type === 'hasMany' || rel.type === 'belongsToMany')
|
|
22
|
+
.relation('{{ rel.name }}', () => {{ rel.model }}Factory)
|
|
23
|
+
@end
|
|
24
|
+
@end
|
|
25
|
+
.build()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('app/mails', entity.path, entity.name.toLowerCase() + '.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { BaseMail } from '@adonisjs/mail'
|
|
7
|
+
|
|
8
|
+
export default class {{ entity.className }} extends BaseMail {
|
|
9
|
+
from = 'admin@example.com'
|
|
10
|
+
subject = 'Subject'
|
|
11
|
+
|
|
12
|
+
constructor(public payload: any) {
|
|
13
|
+
super()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The "build" method is used to configure the mail
|
|
18
|
+
* message.
|
|
19
|
+
*/
|
|
20
|
+
async build() {
|
|
21
|
+
this.message.to('user@example.com')
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('app/middleware', entity.path, entity.name.toLowerCase() + '_middleware.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { HttpContext } from '@adonisjs/core/http'
|
|
7
|
+
import { NextFn } from '@adonisjs/core/types/http'
|
|
8
|
+
|
|
9
|
+
export default class {{ entity.className }}Middleware {
|
|
10
|
+
async handle(ctx: HttpContext, next: NextFn) {
|
|
11
|
+
/**
|
|
12
|
+
* Middleware logic goes here
|
|
13
|
+
*/
|
|
14
|
+
return next()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('database/migrations', entity.path, Date.now() + '_' + entity.tableName + '.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
7
|
+
|
|
8
|
+
export default class extends BaseSchema {
|
|
9
|
+
protected tableName = '{{ entity.tableName }}'
|
|
10
|
+
|
|
11
|
+
async up() {
|
|
12
|
+
this.schema.createTable(this.tableName, (table) => {
|
|
13
|
+
table.increments('id').primary()
|
|
14
|
+
@each(attribute in attributes)
|
|
15
|
+
{{ attribute.migrationLine }}
|
|
16
|
+
@end
|
|
17
|
+
table.timestamp('created_at')
|
|
18
|
+
table.timestamp('updated_at')
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async down() {
|
|
23
|
+
this.schema.dropTable(this.tableName)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('app/models', entity.path, entity.name.toLowerCase() + '.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
{{{ modelImports }}}
|
|
7
|
+
@each(relationship in relationships)
|
|
8
|
+
{{{ relationship.importLine }}}
|
|
9
|
+
@end
|
|
10
|
+
|
|
11
|
+
{{{ modelSignature }}}
|
|
12
|
+
@each(attribute in attributes)
|
|
13
|
+
{{{ attribute.line }}}
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@each(relationship in relationships)
|
|
17
|
+
{{{ relationship.line }}}
|
|
18
|
+
@end
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('app/notifications', entity.path, string.snakeCase(entity.name) + '_notification.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { Notification } from '@adonisjs/notifications'
|
|
7
|
+
|
|
8
|
+
export default class {{ entity.className }}Notification extends Notification {
|
|
9
|
+
constructor(public payload: any) {
|
|
10
|
+
super()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The notification channels to use
|
|
15
|
+
*/
|
|
16
|
+
via() {
|
|
17
|
+
return ['mail']
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Mail representation
|
|
22
|
+
*/
|
|
23
|
+
toMail() {
|
|
24
|
+
return this.mail()
|
|
25
|
+
.subject('Notification')
|
|
26
|
+
.line('Your notification message')
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('app/policies', entity.path, string.snakeCase(entity.name) + '_policy.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import User from '#models/user'
|
|
7
|
+
import {{ entity.className }} from '#models/{{ string.snakeCase(entity.name) }}'
|
|
8
|
+
import { BasePolicy } from '@adonisjs/bouncer'
|
|
9
|
+
import { AuthorizerResponse } from '@adonisjs/bouncer/types'
|
|
10
|
+
|
|
11
|
+
export default class {{ entity.className }}Policy extends BasePolicy {
|
|
12
|
+
@each(action in actions)
|
|
13
|
+
{{ action.name }}(user: User, {{ action.variableName }}: {{ action.modelName }}): AuthorizerResponse {
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
@end
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('database/seeders', entity.path, entity.name.toLowerCase() + '_seeder.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { BaseSeeder } from '@adonisjs/lucid/seeders'
|
|
7
|
+
@if(data)
|
|
8
|
+
import {{ entity.className }} from '#models/{{ entity.name.toLowerCase() }}'
|
|
9
|
+
@else
|
|
10
|
+
import { {{ entity.className }}Factory } from '#database/factories/{{ entity.name.toLowerCase() }}_factory'
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
export default class extends BaseSeeder {
|
|
14
|
+
async run() {
|
|
15
|
+
@if(data)
|
|
16
|
+
await {{ entity.className }}.createMany({{ inspect(data) }})
|
|
17
|
+
@else
|
|
18
|
+
await {{ entity.className }}Factory.createMany({{ count }})
|
|
19
|
+
@end
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('tests/functional', entity.path, string.snakeCase(entity.name) + '.spec.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { test } from '@japa/runner'
|
|
7
|
+
@if(hasAuth)
|
|
8
|
+
import User from '#models/user'
|
|
9
|
+
@end
|
|
10
|
+
|
|
11
|
+
test.group('{{ entity.className }} Controller', () => {
|
|
12
|
+
@each(action in actions)
|
|
13
|
+
test('{{ action.name }}', async ({ client }) => {
|
|
14
|
+
@if(action.auth)
|
|
15
|
+
const user = await User.create({})
|
|
16
|
+
const response = await client.{{ action.method }}('{{ action.url }}').loginAs(user)
|
|
17
|
+
@else
|
|
18
|
+
const response = await client.{{ action.method }}('{{ action.url }}')
|
|
19
|
+
@end
|
|
20
|
+
response.assertStatus(200)
|
|
21
|
+
})
|
|
22
|
+
@end
|
|
23
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('app/validators', entity.path, entity.name + '.ts')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import vine from '@vinejs/vine'
|
|
7
|
+
|
|
8
|
+
export const create{{ entity.className }}Validator = vine.compile(
|
|
9
|
+
vine.object({
|
|
10
|
+
@each(attribute in attributes)
|
|
11
|
+
{{ attribute.name }}: vine.{{ attribute.vineType }}(),
|
|
12
|
+
@end
|
|
13
|
+
})
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
export const update{{ entity.className }}Validator = vine.compile(
|
|
17
|
+
vine.object({
|
|
18
|
+
@each(attribute in attributes)
|
|
19
|
+
{{ attribute.name }}: vine.{{ attribute.vineType }}().optional(),
|
|
20
|
+
@end
|
|
21
|
+
})
|
|
22
|
+
)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('resources/views', entity.path, entity.name.toLowerCase() + '.edge')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
@layout.app({ title: '{{ entity.className }} {{ action }}' })
|
|
7
|
+
|
|
8
|
+
@slot('main')
|
|
9
|
+
<div class="container p-8">
|
|
10
|
+
<h1 class="text-3xl font-bold mb-6 capitalize">{{ folder }} {{ action }}</h1>
|
|
11
|
+
|
|
12
|
+
@if(action === 'index')
|
|
13
|
+
<div class="overflow-x-auto">
|
|
14
|
+
<table class="min-w-full bg-white border">
|
|
15
|
+
<thead>
|
|
16
|
+
<tr>
|
|
17
|
+
@each(attr in attributes)
|
|
18
|
+
<th class="px-4 py-2 border-b text-left">{{ attr.name }}</th>
|
|
19
|
+
@end
|
|
20
|
+
<th class="px-4 py-2 border-b text-left">Actions</th>
|
|
21
|
+
</tr>
|
|
22
|
+
</thead>
|
|
23
|
+
<tbody>
|
|
24
|
+
@each(item in {{ entity.name.toLowerCase() }}s)
|
|
25
|
+
<tr>
|
|
26
|
+
@each(attr in attributes)
|
|
27
|
+
<td class="px-4 py-2 border-b text-left">\{{ item.{{ attr.name }} }}</td>
|
|
28
|
+
@end
|
|
29
|
+
<td class="px-4 py-2 border-b text-left text-blue-500">
|
|
30
|
+
{/* actions placeholder */}
|
|
31
|
+
</td>
|
|
32
|
+
</tr>
|
|
33
|
+
@end
|
|
34
|
+
</tbody>
|
|
35
|
+
</table>
|
|
36
|
+
</div>
|
|
37
|
+
@elseif(action === 'create' || action === 'edit')
|
|
38
|
+
<form action="{{ '{{' }} route('{{ folder }}.store') {{ '}}' }}" method="POST" class="max-w-lg">
|
|
39
|
+
\{{ csrfField() }}
|
|
40
|
+
@each(attr in attributes)
|
|
41
|
+
<div class="mb-4">
|
|
42
|
+
<label class="block text-gray-700 text-sm font-bold mb-2">{{ attr.name }}</label>
|
|
43
|
+
<input
|
|
44
|
+
type="text"
|
|
45
|
+
name="{{ attr.name }}"
|
|
46
|
+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
@end
|
|
50
|
+
<button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
|
|
51
|
+
Save
|
|
52
|
+
</button>
|
|
53
|
+
</form>
|
|
54
|
+
@else
|
|
55
|
+
<div class="bg-white shadow rounded-lg p-6">
|
|
56
|
+
@each(attr in attributes)
|
|
57
|
+
<div class="mb-4">
|
|
58
|
+
<span class="font-bold">{{ attr.name }}:</span>
|
|
59
|
+
<span class="ml-2">\{{ {{ entity.name.toLowerCase() }}?.{{ attr.name }} }}</span>
|
|
60
|
+
</div>
|
|
61
|
+
@end
|
|
62
|
+
</div>
|
|
63
|
+
@end
|
|
64
|
+
</div>
|
|
65
|
+
@endslot
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('inertia/pages', entity.path, entity.name.toLowerCase() + '.tsx')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { Head } from '@inertiajs/react'
|
|
7
|
+
|
|
8
|
+
export default function {{ entity.className }}(props: any) {
|
|
9
|
+
return (
|
|
10
|
+
<div className="container p-8">
|
|
11
|
+
<Head title="{{ entity.className }} {{ action }}" />
|
|
12
|
+
<h1 className="text-3xl font-bold mb-6 capitalize">{{ entity.className }} {{ action }}</h1>
|
|
13
|
+
|
|
14
|
+
@if(action === 'index')
|
|
15
|
+
<div className="overflow-x-auto">
|
|
16
|
+
<table className="min-w-full bg-white border">
|
|
17
|
+
<thead>
|
|
18
|
+
<tr>
|
|
19
|
+
@each(attr in attributes)
|
|
20
|
+
<th className="px-4 py-2 border-b text-left">{{ attr.name }}</th>
|
|
21
|
+
@end
|
|
22
|
+
<th className="px-4 py-2 border-b text-left">Actions</th>
|
|
23
|
+
</tr>
|
|
24
|
+
</thead>
|
|
25
|
+
<tbody>
|
|
26
|
+
{/* Logic for mapping data goes here */}
|
|
27
|
+
</tbody>
|
|
28
|
+
</table>
|
|
29
|
+
</div>
|
|
30
|
+
@elseif(action === 'create' || action === 'edit')
|
|
31
|
+
<form className="max-w-lg">
|
|
32
|
+
@each(attr in attributes)
|
|
33
|
+
<div className="mb-4">
|
|
34
|
+
<label className="block text-gray-700 text-sm font-bold mb-2">{{ attr.name }}</label>
|
|
35
|
+
<input
|
|
36
|
+
type="text"
|
|
37
|
+
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
@end
|
|
41
|
+
<button className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
|
|
42
|
+
Save
|
|
43
|
+
</button>
|
|
44
|
+
</form>
|
|
45
|
+
@else
|
|
46
|
+
<div className="bg-white shadow rounded-lg p-6">
|
|
47
|
+
@each(attr in attributes)
|
|
48
|
+
<div className="mb-4">
|
|
49
|
+
<span className="font-bold">{{ attr.name }}:</span>
|
|
50
|
+
<span className="ml-2">{props.{{ entity.name.toLowerCase() }}?.{{ attr.name }}}</span>
|
|
51
|
+
</div>
|
|
52
|
+
@end
|
|
53
|
+
</div>
|
|
54
|
+
@end
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('inertia/pages', entity.path, entity.name.toLowerCase() + '.svelte')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { Head } from '@inertiajs/svelte'
|
|
8
|
+
|
|
9
|
+
export let {{ entity.name.toLowerCase() }} = null;
|
|
10
|
+
export let {{ entity.name.toLowerCase() }}s = [];
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class="container p-8">
|
|
14
|
+
<Head title="{{ entity.className }} {{ action }}" />
|
|
15
|
+
<h1 class="text-3xl font-bold mb-6 capitalize">{{ folder }} {{ action }}</h1>
|
|
16
|
+
|
|
17
|
+
{#if action === 'index'}
|
|
18
|
+
<div class="overflow-x-auto">
|
|
19
|
+
<table class="min-w-full bg-white border">
|
|
20
|
+
<thead>
|
|
21
|
+
<tr>
|
|
22
|
+
@each(attr in attributes)
|
|
23
|
+
<th class="px-4 py-2 border-b text-left">{{ attr.name }}</th>
|
|
24
|
+
@end
|
|
25
|
+
<th class="px-4 py-2 border-b text-left">Actions</th>
|
|
26
|
+
</tr>
|
|
27
|
+
</thead>
|
|
28
|
+
<tbody>
|
|
29
|
+
{#each {{ entity.name.toLowerCase() }}s as item}
|
|
30
|
+
<tr>
|
|
31
|
+
@each(attr in attributes)
|
|
32
|
+
<td class="px-4 py-2 border-b text-left">{item.{{ attr.name }}}</td>
|
|
33
|
+
@end
|
|
34
|
+
<td class="px-4 py-2 border-b text-left text-blue-500">
|
|
35
|
+
{/* actions placeholder */}
|
|
36
|
+
</td>
|
|
37
|
+
</tr>
|
|
38
|
+
{/each}
|
|
39
|
+
</tbody>
|
|
40
|
+
</table>
|
|
41
|
+
</div>
|
|
42
|
+
{:else if action === 'create' || action === 'edit'}
|
|
43
|
+
<form class="max-w-lg">
|
|
44
|
+
@each(attr in attributes)
|
|
45
|
+
<div class="mb-4">
|
|
46
|
+
<label class="block text-gray-700 text-sm font-bold mb-2">{{ attr.name }}</label>
|
|
47
|
+
<input
|
|
48
|
+
type="text"
|
|
49
|
+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
@end
|
|
53
|
+
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
|
|
54
|
+
Save
|
|
55
|
+
</button>
|
|
56
|
+
</form>
|
|
57
|
+
{:else}
|
|
58
|
+
<div class="bg-white shadow rounded-lg p-6">
|
|
59
|
+
@each(attr in attributes)
|
|
60
|
+
<div class="mb-4">
|
|
61
|
+
<span class="font-bold">{{ attr.name }}:</span>
|
|
62
|
+
<span class="ml-2">{{ '{' }}{{ entity.name.toLowerCase() }}?.{{ attr.name }}{{ '}' }}</span>
|
|
63
|
+
</div>
|
|
64
|
+
@end
|
|
65
|
+
</div>
|
|
66
|
+
{/if}
|
|
67
|
+
</div>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath('inertia/pages', entity.path, entity.name.toLowerCase() + '.vue')
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
<script setup lang="ts">
|
|
7
|
+
import { Head } from '@inertiajs/vue3'
|
|
8
|
+
|
|
9
|
+
defineProps<{
|
|
10
|
+
{{ entity.name.toLowerCase() }}?: any
|
|
11
|
+
{{ entity.name.toLowerCase() }}s?: any[]
|
|
12
|
+
[key: string]: any
|
|
13
|
+
}>()
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div class="container p-8">
|
|
18
|
+
<Head :title="`{{ entity.className }} {{ action }}`" />
|
|
19
|
+
<h1 class="text-3xl font-bold mb-6 capitalize">{{ folder }} {{ action }}</h1>
|
|
20
|
+
|
|
21
|
+
<template v-if="action === 'index'">
|
|
22
|
+
<div class="overflow-x-auto">
|
|
23
|
+
<table class="min-w-full bg-white border">
|
|
24
|
+
<thead>
|
|
25
|
+
<tr>
|
|
26
|
+
@each(attr in attributes)
|
|
27
|
+
<th class="px-4 py-2 border-b text-left">{{ attr.name }}</th>
|
|
28
|
+
@end
|
|
29
|
+
<th class="px-4 py-2 border-b text-left">Actions</th>
|
|
30
|
+
</tr>
|
|
31
|
+
</thead>
|
|
32
|
+
<tbody>
|
|
33
|
+
<tr v-for="item in {{ entity.name.toLowerCase() }}s" :key="item.id">
|
|
34
|
+
@each(attr in attributes)
|
|
35
|
+
<td class="px-4 py-2 border-b text-left">{{ '{{' }} item.{{ attr.name }} {{ '}}' }}</td>
|
|
36
|
+
@end
|
|
37
|
+
<td class="px-4 py-2 border-b text-left text-blue-500">
|
|
38
|
+
{/* actions placeholder */}
|
|
39
|
+
</td>
|
|
40
|
+
</tr>
|
|
41
|
+
</tbody>
|
|
42
|
+
</table>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<template v-else-if="action === 'create' || action === 'edit'">
|
|
47
|
+
<form class="max-w-lg">
|
|
48
|
+
@each(attr in attributes)
|
|
49
|
+
<div class="mb-4">
|
|
50
|
+
<label class="block text-gray-700 text-sm font-bold mb-2">{{ attr.name }}</label>
|
|
51
|
+
<input
|
|
52
|
+
type="text"
|
|
53
|
+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
@end
|
|
57
|
+
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
|
|
58
|
+
Save
|
|
59
|
+
</button>
|
|
60
|
+
</form>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<template v-else>
|
|
64
|
+
<div class="bg-white shadow rounded-lg p-6">
|
|
65
|
+
@each(attr in attributes)
|
|
66
|
+
<div class="mb-4">
|
|
67
|
+
<span class="font-bold">{{ attr.name }}:</span>
|
|
68
|
+
<span class="ml-2">{{ '{{' }} {{ entity.name.toLowerCase() }}?.{{ attr.name }} {{ '}}' }}</span>
|
|
69
|
+
</div>
|
|
70
|
+
@end
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
package/build/main-1fZp_M_R.js
DELETED
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
1
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { parse } from "yaml";
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
5
|
//#region \0rolldown/runtime.js
|
|
6
6
|
var __create = Object.create;
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
File without changes
|