@anu8151/adonisjs-blueprint 0.3.1 → 0.3.3
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.
|
@@ -0,0 +1,177 @@
|
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
-
export
|
|
2
|
+
export default class BuildBlueprint extends BaseCommand {
|
|
3
3
|
static commandName: string;
|
|
4
4
|
static description: string;
|
|
5
5
|
draftFile: string;
|
|
@@ -11,4 +11,3 @@ export declare class BuildBlueprint extends BaseCommand {
|
|
|
11
11
|
private eraseExisting;
|
|
12
12
|
private build;
|
|
13
13
|
}
|
|
14
|
-
export default BuildBlueprint;
|
|
@@ -1,177 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
|
|
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
|
|
177
|
-
export { BuildBlueprint, BuildBlueprint as default };
|
|
1
|
+
import { t as BuildBlueprint } from "../../build-CWtJ8mPG.js";
|
|
2
|
+
export { BuildBlueprint as default };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import EraseBlueprint from './erase.js';
|
|
2
|
+
export declare const commands: (typeof EraseBlueprint)[];
|
|
@@ -1,10 +1,77 @@
|
|
|
1
|
+
import { t as BuildBlueprint } from "../../build-CWtJ8mPG.js";
|
|
2
|
+
import EraseBlueprint from "./erase.js";
|
|
3
|
+
import TraceBlueprint from "./trace.js";
|
|
4
|
+
import EjectStubs from "./stubs.js";
|
|
5
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { BaseCommand } from "@adonisjs/core/ace";
|
|
7
|
+
//#region src/commands/init.ts
|
|
8
|
+
var InitBlueprint = class extends BaseCommand {
|
|
9
|
+
static commandName = "blueprint:init";
|
|
10
|
+
static description = "Initialize a draft.yaml file with a professional-grade example";
|
|
11
|
+
async run() {
|
|
12
|
+
const draftPath = this.app.makePath("draft.yaml");
|
|
13
|
+
if (existsSync(draftPath)) {
|
|
14
|
+
if (!await this.prompt.confirm("A draft.yaml already exists. Do you want to overwrite it?")) {
|
|
15
|
+
this.logger.info("Initialization cancelled.");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
writeFileSync(draftPath, `# yaml-language-server: $schema=node_modules/@anu8151/adonisjs-blueprint/build/src/schema.json
|
|
20
|
+
|
|
21
|
+
settings:
|
|
22
|
+
api: true
|
|
23
|
+
inertia:
|
|
24
|
+
enabled: false
|
|
25
|
+
adapter: react
|
|
26
|
+
|
|
27
|
+
# Define your models here
|
|
28
|
+
models:
|
|
29
|
+
User:
|
|
30
|
+
attributes:
|
|
31
|
+
email: string:unique
|
|
32
|
+
password: string
|
|
33
|
+
full_name: string:optional
|
|
34
|
+
relationships:
|
|
35
|
+
posts: hasMany
|
|
36
|
+
|
|
37
|
+
Post:
|
|
38
|
+
attributes:
|
|
39
|
+
title: string:min:5
|
|
40
|
+
content: text
|
|
41
|
+
status: enum:draft,published,archived
|
|
42
|
+
softDeletes: true
|
|
43
|
+
relationships:
|
|
44
|
+
user: belongsTo
|
|
45
|
+
tags: belongsToMany
|
|
46
|
+
|
|
47
|
+
Tag:
|
|
48
|
+
attributes:
|
|
49
|
+
name: string:unique
|
|
50
|
+
|
|
51
|
+
# Define your controllers and business logic here
|
|
52
|
+
controllers:
|
|
53
|
+
Post:
|
|
54
|
+
resource: true
|
|
55
|
+
publish:
|
|
56
|
+
query: find
|
|
57
|
+
validate: title, content
|
|
58
|
+
save: true
|
|
59
|
+
fire: PostPublished
|
|
60
|
+
send: NewPostMail
|
|
61
|
+
render: 'json with: post'
|
|
62
|
+
`);
|
|
63
|
+
this.logger.success("draft.yaml initialized successfully.");
|
|
64
|
+
this.logger.info("You can now run: node ace blueprint:build");
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
1
68
|
//#region src/commands/main.ts
|
|
2
69
|
const commands = [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
70
|
+
BuildBlueprint,
|
|
71
|
+
EraseBlueprint,
|
|
72
|
+
TraceBlueprint,
|
|
73
|
+
EjectStubs,
|
|
74
|
+
InitBlueprint
|
|
8
75
|
];
|
|
9
76
|
//#endregion
|
|
10
77
|
export { commands };
|
package/package.json
CHANGED
package/build/init-JJYCiAqQ.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { existsSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { BaseCommand } from "@adonisjs/core/ace";
|
|
3
|
-
//#region src/commands/init.ts
|
|
4
|
-
var InitBlueprint = class extends BaseCommand {
|
|
5
|
-
static commandName = "blueprint:init";
|
|
6
|
-
static description = "Initialize a draft.yaml file with a professional-grade example";
|
|
7
|
-
async run() {
|
|
8
|
-
const draftPath = this.app.makePath("draft.yaml");
|
|
9
|
-
if (existsSync(draftPath)) {
|
|
10
|
-
if (!await this.prompt.confirm("A draft.yaml already exists. Do you want to overwrite it?")) {
|
|
11
|
-
this.logger.info("Initialization cancelled.");
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
writeFileSync(draftPath, `# yaml-language-server: $schema=node_modules/@anu8151/adonisjs-blueprint/build/src/schema.json
|
|
16
|
-
|
|
17
|
-
settings:
|
|
18
|
-
api: true
|
|
19
|
-
inertia:
|
|
20
|
-
enabled: false
|
|
21
|
-
adapter: react
|
|
22
|
-
|
|
23
|
-
# Define your models here
|
|
24
|
-
models:
|
|
25
|
-
User:
|
|
26
|
-
attributes:
|
|
27
|
-
email: string:unique
|
|
28
|
-
password: string
|
|
29
|
-
full_name: string:optional
|
|
30
|
-
relationships:
|
|
31
|
-
posts: hasMany
|
|
32
|
-
|
|
33
|
-
Post:
|
|
34
|
-
attributes:
|
|
35
|
-
title: string:min:5
|
|
36
|
-
content: text
|
|
37
|
-
status: enum:draft,published,archived
|
|
38
|
-
softDeletes: true
|
|
39
|
-
relationships:
|
|
40
|
-
user: belongsTo
|
|
41
|
-
tags: belongsToMany
|
|
42
|
-
|
|
43
|
-
Tag:
|
|
44
|
-
attributes:
|
|
45
|
-
name: string:unique
|
|
46
|
-
|
|
47
|
-
# Define your controllers and business logic here
|
|
48
|
-
controllers:
|
|
49
|
-
Post:
|
|
50
|
-
resource: true
|
|
51
|
-
publish:
|
|
52
|
-
query: find
|
|
53
|
-
validate: title, content
|
|
54
|
-
save: true
|
|
55
|
-
fire: PostPublished
|
|
56
|
-
send: NewPostMail
|
|
57
|
-
render: 'json with: post'
|
|
58
|
-
`);
|
|
59
|
-
this.logger.success("draft.yaml initialized successfully.");
|
|
60
|
-
this.logger.info("You can now run: node ace blueprint:build");
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
//#endregion
|
|
64
|
-
export { InitBlueprint as default };
|