@anu8151/adonisjs-blueprint 0.3.6 → 0.3.8
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 +8 -1
- package/build/{event_generator-B83LtJmu.d.ts → event_generator-oIEH7_oz.d.ts} +1 -1
- package/build/{job_generator-GmmbUvVL.d.ts → job_generator-HTTatdkn.d.ts} +1 -1
- package/build/{mail_generator-B-TNNzl3.d.ts → mail_generator-DDzgqB7F.d.ts} +1 -1
- package/build/{notification_generator-C8kSV8HA.d.ts → notification_generator-Ckyi9uwv.d.ts} +1 -1
- package/build/{service_generator-Slb920qs.d.ts → service_generator-JwNPzTLC.d.ts} +1 -1
- package/build/src/commands/build.js +176 -1
- package/build/src/commands/main.d.ts +1 -2
- package/package.json +7 -4
- package/build/build-CWtJ8mPG.js +0 -177
- package/build/src/commands/main.js +0 -15
- /package/build/{base_generator-ClKso0XJ.d.ts → base_generator-DnmbQ4rq.d.ts} +0 -0
- /package/build/{types-DTlzGpWR.d.ts → types-Cyzao-RJ.d.ts} +0 -0
package/build/configure.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { stubsRoot } from "./stubs/main.js";
|
|
2
2
|
//#region configure.ts
|
|
3
3
|
async function configure(command) {
|
|
4
|
+
const codemods = await command.createCodemods();
|
|
4
5
|
/**
|
|
5
6
|
* Publish config file
|
|
6
7
|
*/
|
|
7
|
-
await
|
|
8
|
+
await codemods.makeUsingStub(stubsRoot, "config.stub", {});
|
|
9
|
+
/**
|
|
10
|
+
* Register commands in adonisrc.ts
|
|
11
|
+
*/
|
|
12
|
+
await codemods.updateRcFile((rcFile) => {
|
|
13
|
+
rcFile.addCommand("@anu8151/adonisjs-blueprint");
|
|
14
|
+
});
|
|
8
15
|
}
|
|
9
16
|
//#endregion
|
|
10
17
|
export { configure };
|
|
@@ -1,2 +1,177 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as BlueprintParser } from "../../parser-CmOj1YQa.js";
|
|
2
|
+
import { ModelGenerator } from "../generators/model_generator.js";
|
|
3
|
+
import { MigrationGenerator } from "../generators/migration_generator.js";
|
|
4
|
+
import { ControllerGenerator } from "../generators/controller_generator.js";
|
|
5
|
+
import { ValidatorGenerator } from "../generators/validator_generator.js";
|
|
6
|
+
import { FactoryGenerator } from "../generators/factory_generator.js";
|
|
7
|
+
import { RouteGenerator } from "../generators/route_generator.js";
|
|
8
|
+
import { TestGenerator } from "../generators/test_generator.js";
|
|
9
|
+
import { ViewGenerator } from "../generators/view_generator.js";
|
|
10
|
+
import { SeederGenerator } from "../generators/seeder_generator.js";
|
|
11
|
+
import { PolicyGenerator } from "../generators/policy_generator.js";
|
|
12
|
+
import { EnumGenerator } from "../generators/enum_generator.js";
|
|
13
|
+
import { MiddlewareGenerator } from "../generators/middleware_generator.js";
|
|
14
|
+
import { OpenAPIGenerator } from "../generators/openapi_generator.js";
|
|
15
|
+
import { ChannelGenerator } from "../generators/channel_generator.js";
|
|
16
|
+
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { BaseCommand, args, flags } from "@adonisjs/core/ace";
|
|
18
|
+
import string from "@adonisjs/core/helpers/string";
|
|
19
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/decorate.js
|
|
20
|
+
function __decorate(decorators, target, key, desc) {
|
|
21
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
23
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
24
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/commands/build.ts
|
|
28
|
+
var BuildBlueprint = class extends BaseCommand {
|
|
29
|
+
static commandName = "blueprint:build";
|
|
30
|
+
static description = "Build the application from the draft.yaml file";
|
|
31
|
+
manifest = [];
|
|
32
|
+
async run() {
|
|
33
|
+
if (this.watch) {
|
|
34
|
+
this.logger.info(`Watching for changes in ${this.draftFile}...`);
|
|
35
|
+
const { watch } = await import("node:fs");
|
|
36
|
+
await this.build();
|
|
37
|
+
watch(this.app.makePath(this.draftFile)).on("change", async () => {
|
|
38
|
+
this.logger.info("Changes detected, rebuilding...");
|
|
39
|
+
await this.build();
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
await this.build();
|
|
44
|
+
}
|
|
45
|
+
async eraseExisting() {
|
|
46
|
+
const manifestPath = this.app.makePath(".blueprint_manifest.json");
|
|
47
|
+
if (existsSync(manifestPath)) {
|
|
48
|
+
this.logger.info("Erasing existing generated files...");
|
|
49
|
+
const files = JSON.parse(readFileSync(manifestPath, "utf8")).files || [];
|
|
50
|
+
for (const file of files) if (existsSync(file)) {
|
|
51
|
+
unlinkSync(file);
|
|
52
|
+
this.logger.action(`deleted ${file}`).succeeded();
|
|
53
|
+
}
|
|
54
|
+
unlinkSync(manifestPath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async build() {
|
|
58
|
+
if (this.erase) await this.eraseExisting();
|
|
59
|
+
this.logger.info("Building application from " + this.draftFile);
|
|
60
|
+
const blueprint = await new BlueprintParser().parse(this.draftFile);
|
|
61
|
+
this.manifest = [];
|
|
62
|
+
if (blueprint.auth) {
|
|
63
|
+
this.logger.info("Auth shorthand detected. Injecting AuthController...");
|
|
64
|
+
if (!blueprint.controllers) blueprint.controllers = {};
|
|
65
|
+
if (!blueprint.controllers["Auth"]) blueprint.controllers["Auth"] = {
|
|
66
|
+
login: { render: "auth/login" },
|
|
67
|
+
register: { render: "auth/register" },
|
|
68
|
+
store: {
|
|
69
|
+
validate: "email, password",
|
|
70
|
+
auth: "true",
|
|
71
|
+
redirect: "dashboard"
|
|
72
|
+
},
|
|
73
|
+
logout: {
|
|
74
|
+
auth: "logout",
|
|
75
|
+
redirect: "login"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
if (!blueprint.models) blueprint.models = {};
|
|
79
|
+
if (!blueprint.models["User"]) blueprint.models["User"] = { attributes: {
|
|
80
|
+
email: "string:unique",
|
|
81
|
+
password: "string",
|
|
82
|
+
full_name: "string:optional"
|
|
83
|
+
} };
|
|
84
|
+
}
|
|
85
|
+
const forceOverwrite = this.force || this.erase;
|
|
86
|
+
if (blueprint.models) {
|
|
87
|
+
const modelGenerator = new ModelGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
88
|
+
const migrationGenerator = new MigrationGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
89
|
+
const validatorGenerator = new ValidatorGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
90
|
+
const factoryGenerator = new FactoryGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
91
|
+
const seederGenerator = new SeederGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
92
|
+
const enumGenerator = new EnumGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
93
|
+
for (const [name, definition] of Object.entries(blueprint.models)) {
|
|
94
|
+
this.logger.info(`Generating model, migration, validator, factory and seeder for ${name}`);
|
|
95
|
+
await modelGenerator.generate(name, definition);
|
|
96
|
+
await migrationGenerator.generate(name, definition);
|
|
97
|
+
await validatorGenerator.generate(name, definition);
|
|
98
|
+
await factoryGenerator.generate(name, definition);
|
|
99
|
+
await seederGenerator.generate(name, definition);
|
|
100
|
+
if (definition.attributes) {
|
|
101
|
+
for (const [attrName, attrType] of Object.entries(definition.attributes)) if (typeof attrType === "string" && attrType.startsWith("enum:")) {
|
|
102
|
+
const enumName = string.pascalCase(name + "_" + attrName);
|
|
103
|
+
const values = attrType.split(":")[1].split(",").map((v) => v.trim());
|
|
104
|
+
this.logger.info(`Generating enum ${enumName}`);
|
|
105
|
+
await enumGenerator.generate(enumName, { values });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (blueprint.controllers) {
|
|
111
|
+
const controllerGenerator = new ControllerGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
112
|
+
const routeGenerator = new RouteGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
113
|
+
const testGenerator = new TestGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
114
|
+
const viewGenerator = new ViewGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
115
|
+
const policyGenerator = new PolicyGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
116
|
+
const middlewareGenerator = new MiddlewareGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
117
|
+
const useInertia = blueprint.settings?.inertia?.enabled || false;
|
|
118
|
+
const adapter = blueprint.settings?.inertia?.adapter || "react";
|
|
119
|
+
const isApi = blueprint.settings?.api || false;
|
|
120
|
+
for (const [name, definition] of Object.entries(blueprint.controllers)) {
|
|
121
|
+
this.logger.info(`Generating controller, routes, tests and policies for ${name}`);
|
|
122
|
+
await controllerGenerator.generate(name, definition, useInertia, isApi, blueprint.models);
|
|
123
|
+
await routeGenerator.generate(name, definition, isApi);
|
|
124
|
+
await testGenerator.generate(name, definition, blueprint);
|
|
125
|
+
await policyGenerator.generate(name, definition);
|
|
126
|
+
if (definition.middleware) {
|
|
127
|
+
for (const mw of definition.middleware) if (![
|
|
128
|
+
"auth",
|
|
129
|
+
"guest",
|
|
130
|
+
"silentAuth"
|
|
131
|
+
].includes(mw)) {
|
|
132
|
+
this.logger.info(`Generating middleware ${mw}`);
|
|
133
|
+
await middlewareGenerator.generate(mw);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (!isApi) {
|
|
137
|
+
for (const actionDef of Object.values(definition)) if (typeof actionDef === "object" && actionDef !== null && actionDef.render) {
|
|
138
|
+
const viewPath = actionDef.render;
|
|
139
|
+
this.logger.info(`Generating view ${viewPath} (${useInertia ? adapter : "edge"})`);
|
|
140
|
+
const modelName = string.pascalCase(string.singular(name));
|
|
141
|
+
const modelDef = blueprint.models ? blueprint.models[modelName] : null;
|
|
142
|
+
await viewGenerator.generate(viewPath, useInertia, adapter, modelDef);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (blueprint.channels) await new ChannelGenerator(this.app, this.logger, this.manifest).generate("", blueprint.channels);
|
|
148
|
+
if (blueprint.settings?.api) {
|
|
149
|
+
this.logger.info("Generating API documentation...");
|
|
150
|
+
await new OpenAPIGenerator(this.app, this.logger, this.manifest).generate("", blueprint);
|
|
151
|
+
}
|
|
152
|
+
if (this.manifest.length > 0) {
|
|
153
|
+
const manifestPath = this.app.makePath(".blueprint_manifest.json");
|
|
154
|
+
writeFileSync(manifestPath, JSON.stringify({ files: this.manifest }, null, 2));
|
|
155
|
+
this.logger.info(`Manifest saved to ${manifestPath}`);
|
|
156
|
+
}
|
|
157
|
+
this.logger.success("Application built successfully");
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
__decorate([args.string({
|
|
161
|
+
description: "The draft file to build from",
|
|
162
|
+
default: "draft.yaml"
|
|
163
|
+
})], BuildBlueprint.prototype, "draftFile", void 0);
|
|
164
|
+
__decorate([flags.boolean({
|
|
165
|
+
alias: "e",
|
|
166
|
+
description: "Erase existing files before building"
|
|
167
|
+
})], BuildBlueprint.prototype, "erase", void 0);
|
|
168
|
+
__decorate([flags.boolean({
|
|
169
|
+
alias: "w",
|
|
170
|
+
description: "Watch the draft file for changes"
|
|
171
|
+
})], BuildBlueprint.prototype, "watch", void 0);
|
|
172
|
+
__decorate([flags.boolean({
|
|
173
|
+
alias: "f",
|
|
174
|
+
description: "Force overwrite existing files"
|
|
175
|
+
})], BuildBlueprint.prototype, "force", void 0);
|
|
176
|
+
//#endregion
|
|
2
177
|
export { BuildBlueprint as default };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const commands: (typeof EraseBlueprint)[];
|
|
1
|
+
export declare const commands: (() => Promise<typeof import("./erase.js")>)[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anu8151/adonisjs-blueprint",
|
|
3
3
|
"description": "Blueprint for AdonisJS 7",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.8",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
".": "./build/index.js",
|
|
18
18
|
"./types": "./build/src/types.js",
|
|
19
|
-
"./commands": "./build/src/commands
|
|
19
|
+
"./commands/*": "./build/src/commands/*.js"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"copy:templates": "copyfiles \"stubs/**/*.stub\" build",
|
|
@@ -81,7 +81,11 @@
|
|
|
81
81
|
],
|
|
82
82
|
"adonisjs": {
|
|
83
83
|
"commands": [
|
|
84
|
-
"@anu8151/adonisjs-blueprint/commands"
|
|
84
|
+
"@anu8151/adonisjs-blueprint/commands/build",
|
|
85
|
+
"@anu8151/adonisjs-blueprint/commands/erase",
|
|
86
|
+
"@anu8151/adonisjs-blueprint/commands/init",
|
|
87
|
+
"@anu8151/adonisjs-blueprint/commands/stubs",
|
|
88
|
+
"@anu8151/adonisjs-blueprint/commands/trace"
|
|
85
89
|
]
|
|
86
90
|
},
|
|
87
91
|
"author": "ANU8151",
|
|
@@ -95,7 +99,6 @@
|
|
|
95
99
|
"./index.ts",
|
|
96
100
|
"./configure.ts",
|
|
97
101
|
"./stubs/main.ts",
|
|
98
|
-
"./src/commands/main.ts",
|
|
99
102
|
"./src/commands/build.ts",
|
|
100
103
|
"./src/commands/erase.ts",
|
|
101
104
|
"./src/commands/trace.ts",
|
package/build/build-CWtJ8mPG.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { t as BlueprintParser } from "./parser-CmOj1YQa.js";
|
|
2
|
-
import { ModelGenerator } from "./src/generators/model_generator.js";
|
|
3
|
-
import { MigrationGenerator } from "./src/generators/migration_generator.js";
|
|
4
|
-
import { ControllerGenerator } from "./src/generators/controller_generator.js";
|
|
5
|
-
import { ValidatorGenerator } from "./src/generators/validator_generator.js";
|
|
6
|
-
import { FactoryGenerator } from "./src/generators/factory_generator.js";
|
|
7
|
-
import { RouteGenerator } from "./src/generators/route_generator.js";
|
|
8
|
-
import { TestGenerator } from "./src/generators/test_generator.js";
|
|
9
|
-
import { ViewGenerator } from "./src/generators/view_generator.js";
|
|
10
|
-
import { SeederGenerator } from "./src/generators/seeder_generator.js";
|
|
11
|
-
import { PolicyGenerator } from "./src/generators/policy_generator.js";
|
|
12
|
-
import { EnumGenerator } from "./src/generators/enum_generator.js";
|
|
13
|
-
import { MiddlewareGenerator } from "./src/generators/middleware_generator.js";
|
|
14
|
-
import { OpenAPIGenerator } from "./src/generators/openapi_generator.js";
|
|
15
|
-
import { ChannelGenerator } from "./src/generators/channel_generator.js";
|
|
16
|
-
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
17
|
-
import { BaseCommand, args, flags } from "@adonisjs/core/ace";
|
|
18
|
-
import string from "@adonisjs/core/helpers/string";
|
|
19
|
-
//#region \0@oxc-project+runtime@0.122.0/helpers/decorate.js
|
|
20
|
-
function __decorate(decorators, target, key, desc) {
|
|
21
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
23
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
24
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/commands/build.ts
|
|
28
|
-
var BuildBlueprint = class extends BaseCommand {
|
|
29
|
-
static commandName = "blueprint:build";
|
|
30
|
-
static description = "Build the application from the draft.yaml file";
|
|
31
|
-
manifest = [];
|
|
32
|
-
async run() {
|
|
33
|
-
if (this.watch) {
|
|
34
|
-
this.logger.info(`Watching for changes in ${this.draftFile}...`);
|
|
35
|
-
const { watch } = await import("node:fs");
|
|
36
|
-
await this.build();
|
|
37
|
-
watch(this.app.makePath(this.draftFile)).on("change", async () => {
|
|
38
|
-
this.logger.info("Changes detected, rebuilding...");
|
|
39
|
-
await this.build();
|
|
40
|
-
});
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
await this.build();
|
|
44
|
-
}
|
|
45
|
-
async eraseExisting() {
|
|
46
|
-
const manifestPath = this.app.makePath(".blueprint_manifest.json");
|
|
47
|
-
if (existsSync(manifestPath)) {
|
|
48
|
-
this.logger.info("Erasing existing generated files...");
|
|
49
|
-
const files = JSON.parse(readFileSync(manifestPath, "utf8")).files || [];
|
|
50
|
-
for (const file of files) if (existsSync(file)) {
|
|
51
|
-
unlinkSync(file);
|
|
52
|
-
this.logger.action(`deleted ${file}`).succeeded();
|
|
53
|
-
}
|
|
54
|
-
unlinkSync(manifestPath);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async build() {
|
|
58
|
-
if (this.erase) await this.eraseExisting();
|
|
59
|
-
this.logger.info("Building application from " + this.draftFile);
|
|
60
|
-
const blueprint = await new BlueprintParser().parse(this.draftFile);
|
|
61
|
-
this.manifest = [];
|
|
62
|
-
if (blueprint.auth) {
|
|
63
|
-
this.logger.info("Auth shorthand detected. Injecting AuthController...");
|
|
64
|
-
if (!blueprint.controllers) blueprint.controllers = {};
|
|
65
|
-
if (!blueprint.controllers["Auth"]) blueprint.controllers["Auth"] = {
|
|
66
|
-
login: { render: "auth/login" },
|
|
67
|
-
register: { render: "auth/register" },
|
|
68
|
-
store: {
|
|
69
|
-
validate: "email, password",
|
|
70
|
-
auth: "true",
|
|
71
|
-
redirect: "dashboard"
|
|
72
|
-
},
|
|
73
|
-
logout: {
|
|
74
|
-
auth: "logout",
|
|
75
|
-
redirect: "login"
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
if (!blueprint.models) blueprint.models = {};
|
|
79
|
-
if (!blueprint.models["User"]) blueprint.models["User"] = { attributes: {
|
|
80
|
-
email: "string:unique",
|
|
81
|
-
password: "string",
|
|
82
|
-
full_name: "string:optional"
|
|
83
|
-
} };
|
|
84
|
-
}
|
|
85
|
-
const forceOverwrite = this.force || this.erase;
|
|
86
|
-
if (blueprint.models) {
|
|
87
|
-
const modelGenerator = new ModelGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
88
|
-
const migrationGenerator = new MigrationGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
89
|
-
const validatorGenerator = new ValidatorGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
90
|
-
const factoryGenerator = new FactoryGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
91
|
-
const seederGenerator = new SeederGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
92
|
-
const enumGenerator = new EnumGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
93
|
-
for (const [name, definition] of Object.entries(blueprint.models)) {
|
|
94
|
-
this.logger.info(`Generating model, migration, validator, factory and seeder for ${name}`);
|
|
95
|
-
await modelGenerator.generate(name, definition);
|
|
96
|
-
await migrationGenerator.generate(name, definition);
|
|
97
|
-
await validatorGenerator.generate(name, definition);
|
|
98
|
-
await factoryGenerator.generate(name, definition);
|
|
99
|
-
await seederGenerator.generate(name, definition);
|
|
100
|
-
if (definition.attributes) {
|
|
101
|
-
for (const [attrName, attrType] of Object.entries(definition.attributes)) if (typeof attrType === "string" && attrType.startsWith("enum:")) {
|
|
102
|
-
const enumName = string.pascalCase(name + "_" + attrName);
|
|
103
|
-
const values = attrType.split(":")[1].split(",").map((v) => v.trim());
|
|
104
|
-
this.logger.info(`Generating enum ${enumName}`);
|
|
105
|
-
await enumGenerator.generate(enumName, { values });
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (blueprint.controllers) {
|
|
111
|
-
const controllerGenerator = new ControllerGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
112
|
-
const routeGenerator = new RouteGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
113
|
-
const testGenerator = new TestGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
114
|
-
const viewGenerator = new ViewGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
115
|
-
const policyGenerator = new PolicyGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
116
|
-
const middlewareGenerator = new MiddlewareGenerator(this.app, this.logger, this.manifest, void 0, forceOverwrite);
|
|
117
|
-
const useInertia = blueprint.settings?.inertia?.enabled || false;
|
|
118
|
-
const adapter = blueprint.settings?.inertia?.adapter || "react";
|
|
119
|
-
const isApi = blueprint.settings?.api || false;
|
|
120
|
-
for (const [name, definition] of Object.entries(blueprint.controllers)) {
|
|
121
|
-
this.logger.info(`Generating controller, routes, tests and policies for ${name}`);
|
|
122
|
-
await controllerGenerator.generate(name, definition, useInertia, isApi, blueprint.models);
|
|
123
|
-
await routeGenerator.generate(name, definition, isApi);
|
|
124
|
-
await testGenerator.generate(name, definition, blueprint);
|
|
125
|
-
await policyGenerator.generate(name, definition);
|
|
126
|
-
if (definition.middleware) {
|
|
127
|
-
for (const mw of definition.middleware) if (![
|
|
128
|
-
"auth",
|
|
129
|
-
"guest",
|
|
130
|
-
"silentAuth"
|
|
131
|
-
].includes(mw)) {
|
|
132
|
-
this.logger.info(`Generating middleware ${mw}`);
|
|
133
|
-
await middlewareGenerator.generate(mw);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (!isApi) {
|
|
137
|
-
for (const actionDef of Object.values(definition)) if (typeof actionDef === "object" && actionDef !== null && actionDef.render) {
|
|
138
|
-
const viewPath = actionDef.render;
|
|
139
|
-
this.logger.info(`Generating view ${viewPath} (${useInertia ? adapter : "edge"})`);
|
|
140
|
-
const modelName = string.pascalCase(string.singular(name));
|
|
141
|
-
const modelDef = blueprint.models ? blueprint.models[modelName] : null;
|
|
142
|
-
await viewGenerator.generate(viewPath, useInertia, adapter, modelDef);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (blueprint.channels) await new ChannelGenerator(this.app, this.logger, this.manifest).generate("", blueprint.channels);
|
|
148
|
-
if (blueprint.settings?.api) {
|
|
149
|
-
this.logger.info("Generating API documentation...");
|
|
150
|
-
await new OpenAPIGenerator(this.app, this.logger, this.manifest).generate("", blueprint);
|
|
151
|
-
}
|
|
152
|
-
if (this.manifest.length > 0) {
|
|
153
|
-
const manifestPath = this.app.makePath(".blueprint_manifest.json");
|
|
154
|
-
writeFileSync(manifestPath, JSON.stringify({ files: this.manifest }, null, 2));
|
|
155
|
-
this.logger.info(`Manifest saved to ${manifestPath}`);
|
|
156
|
-
}
|
|
157
|
-
this.logger.success("Application built successfully");
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
__decorate([args.string({
|
|
161
|
-
description: "The draft file to build from",
|
|
162
|
-
default: "draft.yaml"
|
|
163
|
-
})], BuildBlueprint.prototype, "draftFile", void 0);
|
|
164
|
-
__decorate([flags.boolean({
|
|
165
|
-
alias: "e",
|
|
166
|
-
description: "Erase existing files before building"
|
|
167
|
-
})], BuildBlueprint.prototype, "erase", void 0);
|
|
168
|
-
__decorate([flags.boolean({
|
|
169
|
-
alias: "w",
|
|
170
|
-
description: "Watch the draft file for changes"
|
|
171
|
-
})], BuildBlueprint.prototype, "watch", void 0);
|
|
172
|
-
__decorate([flags.boolean({
|
|
173
|
-
alias: "f",
|
|
174
|
-
description: "Force overwrite existing files"
|
|
175
|
-
})], BuildBlueprint.prototype, "force", void 0);
|
|
176
|
-
//#endregion
|
|
177
|
-
export { BuildBlueprint as t };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { t as BuildBlueprint } from "../../build-CWtJ8mPG.js";
|
|
2
|
-
import EraseBlueprint from "./erase.js";
|
|
3
|
-
import InitBlueprint from "./init.js";
|
|
4
|
-
import TraceBlueprint from "./trace.js";
|
|
5
|
-
import EjectStubs from "./stubs.js";
|
|
6
|
-
//#region src/commands/main.ts
|
|
7
|
-
const commands = [
|
|
8
|
-
BuildBlueprint,
|
|
9
|
-
EraseBlueprint,
|
|
10
|
-
TraceBlueprint,
|
|
11
|
-
EjectStubs,
|
|
12
|
-
InitBlueprint
|
|
13
|
-
];
|
|
14
|
-
//#endregion
|
|
15
|
-
export { commands };
|
|
File without changes
|
|
File without changes
|