@warlock.js/core 4.11.0 → 4.13.0
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 +200 -0
- package/esm/cli/cli-commands.manager.mjs +28 -5
- package/esm/cli/cli-commands.manager.mjs.map +1 -1
- package/esm/cli/commands/add.command.mjs +5 -3
- package/esm/cli/commands/add.command.mjs.map +1 -1
- package/esm/cli/commands/build.command.mjs +1 -1
- package/esm/cli/commands/build.command.mjs.map +1 -1
- package/esm/cli/commands/create-database.command.mjs +1 -1
- package/esm/cli/commands/create-database.command.mjs.map +1 -1
- package/esm/cli/commands/dev-server.command.mjs +1 -1
- package/esm/cli/commands/dev-server.command.mjs.map +1 -1
- package/esm/cli/commands/doctor/doctor-command.action.mjs.map +1 -1
- package/esm/cli/commands/doctor.command.mjs +1 -1
- package/esm/cli/commands/doctor.command.mjs.map +1 -1
- package/esm/cli/commands/drop-tables.command.mjs +1 -1
- package/esm/cli/commands/drop-tables.command.mjs.map +1 -1
- package/esm/cli/commands/generate/generate.command.mjs +43 -22
- package/esm/cli/commands/generate/generate.command.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/controller.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/migration.generator.mjs +1 -1
- package/esm/cli/commands/generate/generators/migration.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/model.generator.mjs +1 -1
- package/esm/cli/commands/generate/generators/model.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/module.generator.mjs +1 -1
- package/esm/cli/commands/generate/generators/module.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/repository.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/resource.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/service.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/utils/path-resolver.mjs +1 -1
- package/esm/cli/commands/generate/utils/writer.mjs +1 -1
- package/esm/cli/commands/migrate.command.mjs +7 -3
- package/esm/cli/commands/migrate.command.mjs.map +1 -1
- package/esm/cli/commands/routes/routes-command.action.mjs.map +1 -1
- package/esm/cli/commands/routes.command.mjs +1 -1
- package/esm/cli/commands/routes.command.mjs.map +1 -1
- package/esm/cli/commands/seed.command.mjs +1 -1
- package/esm/cli/commands/seed.command.mjs.map +1 -1
- package/esm/cli/commands/start-production.command.mjs +1 -1
- package/esm/cli/commands/start-production.command.mjs.map +1 -1
- package/esm/cli/commands/storage-put.action.mjs.map +1 -1
- package/esm/cli/commands/storage-put.command.mjs +1 -1
- package/esm/cli/commands/storage-put.command.mjs.map +1 -1
- package/esm/cli/commands/typings-generator.command.mjs +2 -2
- package/esm/cli/commands/typings-generator.command.mjs.map +1 -1
- package/esm/cli/commands/update.command.mjs +1 -1
- package/esm/cli/commands/update.command.mjs.map +1 -1
- package/esm/cli/commands-loader.mjs +1 -1
- package/esm/cli/commands-loader.mjs.map +1 -1
- package/esm/cli/parse-cli-args.mjs +86 -9
- package/esm/cli/parse-cli-args.mjs.map +1 -1
- package/esm/{cli → commands}/cli-command.d.mts +1 -1
- package/esm/commands/cli-command.d.mts.map +1 -0
- package/esm/{cli → commands}/cli-command.mjs +1 -1
- package/esm/commands/cli-command.mjs.map +1 -0
- package/esm/{cli → commands}/types.d.mts +1 -1
- package/esm/commands/types.d.mts.map +1 -0
- package/esm/config/load-config-files.mjs +1 -1
- package/esm/config/load-config-files.mjs.map +1 -1
- package/esm/connectors/base-connector.mjs +1 -1
- package/esm/connectors/base-connector.mjs.map +1 -1
- package/esm/connectors/connectors-manager.d.mts.map +1 -1
- package/esm/connectors/connectors-manager.mjs +5 -3
- package/esm/connectors/connectors-manager.mjs.map +1 -1
- package/esm/connectors/http-connector.d.mts.map +1 -1
- package/esm/connectors/http-connector.mjs +0 -2
- package/esm/connectors/http-connector.mjs.map +1 -1
- package/esm/database/create-database-action.mjs.map +1 -1
- package/esm/database/drop-tables-action.mjs.map +1 -1
- package/esm/database/migrate-action.mjs +54 -2
- package/esm/database/migrate-action.mjs.map +1 -1
- package/esm/database/pending-exit-code.mjs +39 -0
- package/esm/database/pending-exit-code.mjs.map +1 -0
- package/esm/database/resolve-pending-migrations.mjs +49 -0
- package/esm/database/resolve-pending-migrations.mjs.map +1 -0
- package/esm/database/seed-command-action.mjs +1 -1
- package/esm/database/seed-command-action.mjs.map +1 -1
- package/esm/dev-server/dev-logger.mjs +1 -1
- package/esm/dev-server/dev-logger.mjs.map +1 -1
- package/esm/dev-server/development-server.mjs +2 -2
- package/esm/dev-server/file-event-handler.mjs +1 -1
- package/esm/dev-server/file-event-handler.mjs.map +1 -1
- package/esm/dev-server/file-manager.mjs +1 -1
- package/esm/dev-server/file-manager.mjs.map +1 -1
- package/esm/dev-server/file-operations.mjs +1 -1
- package/esm/dev-server/file-operations.mjs.map +1 -1
- package/esm/dev-server/files-orchestrator.mjs +3 -18
- package/esm/dev-server/files-orchestrator.mjs.map +1 -1
- package/esm/dev-server/files-watcher.mjs +1 -1
- package/esm/dev-server/files-watcher.mjs.map +1 -1
- package/esm/dev-server/health-checker/file-health-checker.contract.d.mts +1 -1
- package/esm/dev-server/layer-executor.mjs +1 -1
- package/esm/dev-server/loader/register-loader.mjs +1 -1
- package/esm/dev-server/package-json-manager.mjs +1 -1
- package/esm/dev-server/package-json-manager.mjs.map +1 -1
- package/esm/dev-server/parse-imports.mjs +2 -2
- package/esm/dev-server/parse-imports.mjs.map +1 -1
- package/esm/dev-server/tsconfig-manager.mjs +1 -1
- package/esm/dev-server/tsconfig-manager.mjs.map +1 -1
- package/esm/dev-server/type-generator.mjs +1 -1
- package/esm/dev-server/type-generator.mjs.map +1 -1
- package/esm/dev-server/utils.mjs +1 -1
- package/esm/dev-server/utils.mjs.map +1 -1
- package/esm/generations/add-command.action.mjs +3 -3
- package/esm/generations/add-command.action.mjs.map +1 -1
- package/esm/http/build-cors-options.mjs +32 -0
- package/esm/http/build-cors-options.mjs.map +1 -0
- package/esm/http/middleware/max-body-size.middleware.d.mts +13 -5
- package/esm/http/middleware/max-body-size.middleware.d.mts.map +1 -1
- package/esm/http/middleware/max-body-size.middleware.mjs +13 -5
- package/esm/http/middleware/max-body-size.middleware.mjs.map +1 -1
- package/esm/http/plugins.d.mts.map +1 -1
- package/esm/http/plugins.mjs +2 -9
- package/esm/http/plugins.mjs.map +1 -1
- package/esm/http/server.d.mts.map +1 -1
- package/esm/http/server.mjs +3 -8
- package/esm/http/server.mjs.map +1 -1
- package/esm/image/image.d.mts +3 -2
- package/esm/image/image.d.mts.map +1 -1
- package/esm/image/image.mjs +63 -17
- package/esm/image/image.mjs.map +1 -1
- package/esm/index.d.mts +9 -17
- package/esm/index.mjs +4 -15
- package/esm/mail/mailer-pool.d.mts.map +1 -1
- package/esm/mail/mailer-pool.mjs.map +1 -1
- package/esm/production/production-builder.mjs +51 -3
- package/esm/production/production-builder.mjs.map +1 -1
- package/esm/production/resolve-build-config.mjs +1 -1
- package/esm/production/resolve-build-config.mjs.map +1 -1
- package/esm/react/index.d.mts +4 -0
- package/esm/react/index.d.mts.map +1 -1
- package/esm/react/index.mjs +88 -14
- package/esm/react/index.mjs.map +1 -1
- package/esm/router/router.d.mts +9 -0
- package/esm/router/router.d.mts.map +1 -1
- package/esm/router/router.mjs +58 -5
- package/esm/router/router.mjs.map +1 -1
- package/esm/router/types.d.mts +24 -1
- package/esm/router/types.d.mts.map +1 -1
- package/esm/tests/index.d.mts +2 -2
- package/esm/tests/index.mjs +1 -2
- package/esm/tests/start-http-development-server.d.mts.map +1 -1
- package/esm/tests/start-http-development-server.mjs +38 -15
- package/esm/tests/start-http-development-server.mjs.map +1 -1
- package/esm/tests/test-helpers.d.mts.map +1 -1
- package/esm/tests/test-helpers.mjs +34 -13
- package/esm/tests/test-helpers.mjs.map +1 -1
- package/esm/tests/vitest-setup.d.mts +1 -1
- package/esm/tests/vitest-setup.d.mts.map +1 -1
- package/esm/tests/vitest-setup.mjs +3 -3
- package/esm/tests/vitest-setup.mjs.map +1 -1
- package/esm/utils/framework-vesion.mjs +1 -1
- package/esm/utils/index.d.mts +1 -0
- package/esm/utils/index.mjs +1 -0
- package/esm/utils/normalized-path.d.mts +55 -0
- package/esm/utils/normalized-path.d.mts.map +1 -0
- package/esm/{dev-server/path.mjs → utils/normalized-path.mjs} +15 -2
- package/esm/utils/normalized-path.mjs.map +1 -0
- package/esm/vite/index.d.mts +2 -0
- package/esm/vite/index.mjs +1 -1
- package/esm/vite/lower-stage3-decorators.d.mts +1 -1
- package/esm/vite/lower-stage3-decorators.mjs +1 -1
- package/esm/vite/lower-stage3-decorators.mjs.map +1 -1
- package/esm/warlock-config/index.mjs +1 -1
- package/esm/warlock-config/types.d.mts +34 -1
- package/esm/warlock-config/types.d.mts.map +1 -1
- package/esm/warlock-config/warlock-config.manager.d.mts.map +1 -1
- package/esm/warlock-config/warlock-config.manager.mjs +1 -2
- package/esm/warlock-config/warlock-config.manager.mjs.map +1 -1
- package/llms-full.txt +78 -23
- package/llms.txt +3 -3
- package/package.json +24 -12
- package/skills/lower-stage3-decorators/SKILL.md +4 -2
- package/skills/process-image/SKILL.md +3 -1
- package/skills/run-app/SKILL.md +6 -0
- package/skills/test-http/SKILL.md +29 -10
- package/skills/test-service/SKILL.md +12 -8
- package/skills/use-middleware/SKILL.md +5 -1
- package/skills/write-cli-command/SKILL.md +19 -1
- package/esm/cli/cli-command.d.mts.map +0 -1
- package/esm/cli/cli-command.mjs.map +0 -1
- package/esm/cli/types.d.mts.map +0 -1
- package/esm/dev-server/files-orchestrator.d.mts +0 -89
- package/esm/dev-server/files-orchestrator.d.mts.map +0 -1
- package/esm/dev-server/files-watcher.d.mts +0 -69
- package/esm/dev-server/files-watcher.d.mts.map +0 -1
- package/esm/dev-server/health-checker/checkers/base-health-checker.d.mts +0 -55
- package/esm/dev-server/health-checker/checkers/base-health-checker.d.mts.map +0 -1
- package/esm/dev-server/health-checker/checkers/eslint-health-checker.d.mts +0 -44
- package/esm/dev-server/health-checker/checkers/eslint-health-checker.d.mts.map +0 -1
- package/esm/dev-server/health-checker/checkers/typescript-health-checker.d.mts +0 -60
- package/esm/dev-server/health-checker/checkers/typescript-health-checker.d.mts.map +0 -1
- package/esm/dev-server/health-checker/files-healthcare.manager.d.mts +0 -119
- package/esm/dev-server/health-checker/files-healthcare.manager.d.mts.map +0 -1
- package/esm/dev-server/health-checker/index.mjs +0 -7
- package/esm/dev-server/module-loader.d.mts +0 -63
- package/esm/dev-server/module-loader.d.mts.map +0 -1
- package/esm/dev-server/path.mjs.map +0 -1
- package/esm/tests/test-server-port-channel.d.mts +0 -27
- package/esm/tests/test-server-port-channel.d.mts.map +0 -1
- /package/esm/{cli → commands}/index.d.mts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { command } from "
|
|
1
|
+
import { command } from "../../../commands/cli-command.mjs";
|
|
2
2
|
import { generateController } from "./generators/controller.generator.mjs";
|
|
3
3
|
import { generateMigration } from "./generators/migration.generator.mjs";
|
|
4
4
|
import { generateModel } from "./generators/model.generator.mjs";
|
|
@@ -50,10 +50,12 @@ const generateCommand = command({
|
|
|
50
50
|
action: generateCommandAction,
|
|
51
51
|
options: [{
|
|
52
52
|
text: "--force, -f",
|
|
53
|
-
description: "Overwrite existing files"
|
|
53
|
+
description: "Overwrite existing files",
|
|
54
|
+
type: "boolean"
|
|
54
55
|
}, {
|
|
55
56
|
text: "--dry-run",
|
|
56
|
-
description: "Preview the files that would be generated without writing anything"
|
|
57
|
+
description: "Preview the files that would be generated without writing anything",
|
|
58
|
+
type: "boolean"
|
|
57
59
|
}]
|
|
58
60
|
});
|
|
59
61
|
const generateModuleCommand = command({
|
|
@@ -64,15 +66,18 @@ const generateModuleCommand = command({
|
|
|
64
66
|
options: [
|
|
65
67
|
{
|
|
66
68
|
text: "--minimal, -m",
|
|
67
|
-
description: "Generate a minimal skeleton (routes, main, locales, empty subfolders) instead of the full CRUD scaffold"
|
|
69
|
+
description: "Generate a minimal skeleton (routes, main, locales, empty subfolders) instead of the full CRUD scaffold",
|
|
70
|
+
type: "boolean"
|
|
68
71
|
},
|
|
69
72
|
{
|
|
70
73
|
text: "--force, -f",
|
|
71
|
-
description: "Overwrite existing files"
|
|
74
|
+
description: "Overwrite existing files",
|
|
75
|
+
type: "boolean"
|
|
72
76
|
},
|
|
73
77
|
{
|
|
74
78
|
text: "--dry-run",
|
|
75
|
-
description: "Preview the files that would be generated without writing anything"
|
|
79
|
+
description: "Preview the files that would be generated without writing anything",
|
|
80
|
+
type: "boolean"
|
|
76
81
|
}
|
|
77
82
|
]
|
|
78
83
|
});
|
|
@@ -84,15 +89,18 @@ const generateControllerCommand = command({
|
|
|
84
89
|
options: [
|
|
85
90
|
{
|
|
86
91
|
text: "--with-validation, -v",
|
|
87
|
-
description: "Generate a validation schema and bind it to the controller"
|
|
92
|
+
description: "Generate a validation schema and bind it to the controller",
|
|
93
|
+
type: "boolean"
|
|
88
94
|
},
|
|
89
95
|
{
|
|
90
96
|
text: "--force, -f",
|
|
91
|
-
description: "Overwrite existing files"
|
|
97
|
+
description: "Overwrite existing files",
|
|
98
|
+
type: "boolean"
|
|
92
99
|
},
|
|
93
100
|
{
|
|
94
101
|
text: "--dry-run",
|
|
95
|
-
description: "Preview the files that would be generated without writing anything"
|
|
102
|
+
description: "Preview the files that would be generated without writing anything",
|
|
103
|
+
type: "boolean"
|
|
96
104
|
}
|
|
97
105
|
]
|
|
98
106
|
});
|
|
@@ -103,10 +111,12 @@ const generateServiceCommand = command({
|
|
|
103
111
|
action: generateService,
|
|
104
112
|
options: [{
|
|
105
113
|
text: "--force, -f",
|
|
106
|
-
description: "Overwrite existing files"
|
|
114
|
+
description: "Overwrite existing files",
|
|
115
|
+
type: "boolean"
|
|
107
116
|
}, {
|
|
108
117
|
text: "--dry-run",
|
|
109
|
-
description: "Preview the files that would be generated without writing anything"
|
|
118
|
+
description: "Preview the files that would be generated without writing anything",
|
|
119
|
+
type: "boolean"
|
|
110
120
|
}]
|
|
111
121
|
});
|
|
112
122
|
const generateModelCommand = command({
|
|
@@ -117,7 +127,8 @@ const generateModelCommand = command({
|
|
|
117
127
|
options: [
|
|
118
128
|
{
|
|
119
129
|
text: "--with-resource, -rs",
|
|
120
|
-
description: "Generate resource"
|
|
130
|
+
description: "Generate resource",
|
|
131
|
+
type: "boolean"
|
|
121
132
|
},
|
|
122
133
|
{
|
|
123
134
|
text: "--table <name>",
|
|
@@ -125,15 +136,18 @@ const generateModelCommand = command({
|
|
|
125
136
|
},
|
|
126
137
|
{
|
|
127
138
|
text: "--force, -f",
|
|
128
|
-
description: "Overwrite existing files"
|
|
139
|
+
description: "Overwrite existing files",
|
|
140
|
+
type: "boolean"
|
|
129
141
|
},
|
|
130
142
|
{
|
|
131
143
|
text: "--dry-run",
|
|
132
|
-
description: "Preview the files that would be generated without writing anything"
|
|
144
|
+
description: "Preview the files that would be generated without writing anything",
|
|
145
|
+
type: "boolean"
|
|
133
146
|
},
|
|
134
147
|
{
|
|
135
148
|
text: "--timestamps [bool]",
|
|
136
|
-
description: "Include timestamps in migration (default: true)"
|
|
149
|
+
description: "Include timestamps in migration (default: true)",
|
|
150
|
+
type: "boolean"
|
|
137
151
|
}
|
|
138
152
|
]
|
|
139
153
|
});
|
|
@@ -144,10 +158,12 @@ const generateRepositoryCommand = command({
|
|
|
144
158
|
action: generateRepository,
|
|
145
159
|
options: [{
|
|
146
160
|
text: "--force, -f",
|
|
147
|
-
description: "Overwrite existing files"
|
|
161
|
+
description: "Overwrite existing files",
|
|
162
|
+
type: "boolean"
|
|
148
163
|
}, {
|
|
149
164
|
text: "--dry-run",
|
|
150
|
-
description: "Preview the files that would be generated without writing anything"
|
|
165
|
+
description: "Preview the files that would be generated without writing anything",
|
|
166
|
+
type: "boolean"
|
|
151
167
|
}]
|
|
152
168
|
});
|
|
153
169
|
const generateResourceCommand = command({
|
|
@@ -157,10 +173,12 @@ const generateResourceCommand = command({
|
|
|
157
173
|
action: generateResource,
|
|
158
174
|
options: [{
|
|
159
175
|
text: "--force, -f",
|
|
160
|
-
description: "Overwrite existing files"
|
|
176
|
+
description: "Overwrite existing files",
|
|
177
|
+
type: "boolean"
|
|
161
178
|
}, {
|
|
162
179
|
text: "--dry-run",
|
|
163
|
-
description: "Preview the files that would be generated without writing anything"
|
|
180
|
+
description: "Preview the files that would be generated without writing anything",
|
|
181
|
+
type: "boolean"
|
|
164
182
|
}]
|
|
165
183
|
});
|
|
166
184
|
const generateMigrationCommand = command({
|
|
@@ -171,11 +189,13 @@ const generateMigrationCommand = command({
|
|
|
171
189
|
options: [
|
|
172
190
|
{
|
|
173
191
|
text: "--force, -f",
|
|
174
|
-
description: "Overwrite existing files"
|
|
192
|
+
description: "Overwrite existing files",
|
|
193
|
+
type: "boolean"
|
|
175
194
|
},
|
|
176
195
|
{
|
|
177
196
|
text: "--dry-run",
|
|
178
|
-
description: "Preview the files that would be generated without writing anything"
|
|
197
|
+
description: "Preview the files that would be generated without writing anything",
|
|
198
|
+
type: "boolean"
|
|
179
199
|
},
|
|
180
200
|
{
|
|
181
201
|
text: "--add <columns>",
|
|
@@ -191,7 +211,8 @@ const generateMigrationCommand = command({
|
|
|
191
211
|
},
|
|
192
212
|
{
|
|
193
213
|
text: "--timestamps [bool]",
|
|
194
|
-
description: "Include timestamps (default: true)"
|
|
214
|
+
description: "Include timestamps (default: true)",
|
|
215
|
+
type: "boolean"
|
|
195
216
|
}
|
|
196
217
|
]
|
|
197
218
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.command.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/generate/generate.command.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport { command } from \"../../cli-command\";\r\nimport type { CommandActionData } from \"../../types\";\r\nimport { generateController } from \"./generators/controller.generator\";\r\nimport { generateMigration } from \"./generators/migration.generator\";\r\nimport { generateModel } from \"./generators/model.generator\";\r\nimport { generateModule } from \"./generators/module.generator\";\r\nimport { generateRepository } from \"./generators/repository.generator\";\r\nimport { generateResource } from \"./generators/resource.generator\";\r\nimport { generateService } from \"./generators/service.generator\";\r\n\r\nconst generators: Record<string, (data: CommandActionData) => Promise<void>> = {\r\n module: generateModule,\r\n controller: generateController,\r\n service: generateService,\r\n model: generateModel,\r\n migration: generateMigration,\r\n repository: generateRepository,\r\n resource: generateResource,\r\n};\r\n\r\nasync function generateCommandAction(data: CommandActionData) {\r\n const commandName = data.args[0];\r\n\r\n if (!commandName) {\r\n console.log(colors.red(\"Error: Generator name is required\"));\r\n console.log(colors.yellow(\"\\nAvailable generators:\"));\r\n Object.keys(generators).forEach((cmd) => {\r\n console.log(colors.cyan(` - ${cmd}`));\r\n });\r\n console.log(colors.yellow(\"\\nUsage: warlock generate <generator> <name> [options]\"));\r\n process.exit(1);\r\n }\r\n\r\n const generator = generators[commandName];\r\n\r\n if (!generator) {\r\n console.log(colors.red(`Error: Unknown generator \"${commandName}\"`));\r\n console.log(colors.yellow(\"\\nAvailable generators:\"));\r\n Object.keys(generators).forEach((cmd) => {\r\n console.log(colors.cyan(` - ${cmd}`));\r\n });\r\n process.exit(1);\r\n }\r\n\r\n // Remove the command name from args for the generator\r\n const generatorData: CommandActionData = {\r\n ...data,\r\n args: data.args.slice(1),\r\n };\r\n\r\n await generator(generatorData);\r\n}\r\n\r\n// Master generate command\r\nexport const generateCommand = command({\r\n name: \"generate <generator> [args...]\",\r\n alias: \"g\", // Allows 'warlock g module ...'\r\n description: \"Scaffold a new component\",\r\n action: generateCommandAction,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n },\r\n ],\r\n});\r\n\r\n// Individual commands\r\nexport const generateModuleCommand = command({\r\n name: \"generate.module <name>\",\r\n alias: \"gen.m\",\r\n description: \"Generate a new module\",\r\n action: generateModule,\r\n options: [\r\n {\r\n text: \"--minimal, -m\",\r\n description:\r\n \"Generate a minimal skeleton (routes, main, locales, empty subfolders) instead of the full CRUD scaffold\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateControllerCommand = command({\r\n name: \"generate.controller <module>/<name>\",\r\n alias: \"gen.c\",\r\n description: \"Generate a new controller\",\r\n action: generateController,\r\n options: [\r\n {\r\n text: \"--with-validation, -v\",\r\n description: \"Generate a validation schema and bind it to the controller\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateServiceCommand = command({\r\n name: \"generate.service <module>/<name>\",\r\n alias: \"gen.s\",\r\n description: \"Generate a new service\",\r\n action: generateService,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateModelCommand = command({\r\n name: \"generate.model <module>/<name>\",\r\n alias: \"gen.md\",\r\n description: \"Generate a new model with migration\",\r\n action: generateModel,\r\n options: [\r\n {\r\n text: \"--with-resource, -rs\",\r\n description: \"Generate resource\",\r\n },\r\n {\r\n text: \"--table <name>\",\r\n description: \"Specify table name\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n },\r\n {\r\n text: \"--timestamps [bool]\",\r\n description: \"Include timestamps in migration (default: true)\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateRepositoryCommand = command({\r\n name: \"generate.repository <module>/<name>\",\r\n alias: \"gen.r\",\r\n description: \"Generate a new repository\",\r\n action: generateRepository,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateResourceCommand = command({\r\n name: \"generate.resource <module>/<name>\",\r\n alias: \"gen.rs\",\r\n description: \"Generate a new resource\",\r\n action: generateResource,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateMigrationCommand = command({\r\n name: \"generate.migration <model-path>\",\r\n alias: \"gen.mig\",\r\n description: \"Generate a new migration for a model\",\r\n action: generateMigration,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n },\r\n {\r\n text: \"--add <columns>\",\r\n description: \"Columns to add (DSL: name:type:modifier,...)\",\r\n },\r\n {\r\n text: \"--drop <columns>\",\r\n description: \"Columns to drop (comma-separated names)\",\r\n },\r\n {\r\n text: \"--rename <columns>\",\r\n description: \"Columns to rename (DSL: old:new,...)\",\r\n },\r\n {\r\n text: \"--timestamps [bool]\",\r\n description: \"Include timestamps (default: true)\",\r\n },\r\n ],\r\n});\r\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,aAAyE;CAC7E,QAAQ;CACR,YAAY;CACZ,SAAS;CACT,OAAO;CACP,WAAW;CACX,YAAY;CACZ,UAAU;AACZ;AAEA,eAAe,sBAAsB,MAAyB;CAC5D,MAAM,cAAc,KAAK,KAAK;CAE9B,IAAI,CAAC,aAAa;EAChB,QAAQ,IAAI,OAAO,IAAI,mCAAmC,CAAC;EAC3D,QAAQ,IAAI,OAAO,OAAO,yBAAyB,CAAC;EACpD,OAAO,KAAK,UAAU,CAAC,CAAC,SAAS,QAAQ;GACvC,QAAQ,IAAI,OAAO,KAAK,OAAO,KAAK,CAAC;EACvC,CAAC;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QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;CACF;AACF,CAAC;AAED,MAAa,4BAA4B,QAAQ;CAC/C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;CACf,GACA;EACE,MAAM;EACN,aAAa;CACf,CACF;AACF,CAAC;AAED,MAAa,0BAA0B,QAAQ;CAC7C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;CACf,GACA;EACE,MAAM;EACN,aAAa;CACf,CACF;AACF,CAAC;AAED,MAAa,2BAA2B,QAAQ;CAC9C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"generate.command.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/generate/generate.command.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport { command } from \"../../../commands/cli-command\";\r\nimport type { CommandActionData } from \"../../../commands/types\";\r\nimport { generateController } from \"./generators/controller.generator\";\r\nimport { generateMigration } from \"./generators/migration.generator\";\r\nimport { generateModel } from \"./generators/model.generator\";\r\nimport { generateModule } from \"./generators/module.generator\";\r\nimport { generateRepository } from \"./generators/repository.generator\";\r\nimport { generateResource } from \"./generators/resource.generator\";\r\nimport { generateService } from \"./generators/service.generator\";\r\n\r\nconst generators: Record<string, (data: CommandActionData) => Promise<void>> = {\r\n module: generateModule,\r\n controller: generateController,\r\n service: generateService,\r\n model: generateModel,\r\n migration: generateMigration,\r\n repository: generateRepository,\r\n resource: generateResource,\r\n};\r\n\r\nasync function generateCommandAction(data: CommandActionData) {\r\n const commandName = data.args[0];\r\n\r\n if (!commandName) {\r\n console.log(colors.red(\"Error: Generator name is required\"));\r\n console.log(colors.yellow(\"\\nAvailable generators:\"));\r\n Object.keys(generators).forEach((cmd) => {\r\n console.log(colors.cyan(` - ${cmd}`));\r\n });\r\n console.log(colors.yellow(\"\\nUsage: warlock generate <generator> <name> [options]\"));\r\n process.exit(1);\r\n }\r\n\r\n const generator = generators[commandName];\r\n\r\n if (!generator) {\r\n console.log(colors.red(`Error: Unknown generator \"${commandName}\"`));\r\n console.log(colors.yellow(\"\\nAvailable generators:\"));\r\n Object.keys(generators).forEach((cmd) => {\r\n console.log(colors.cyan(` - ${cmd}`));\r\n });\r\n process.exit(1);\r\n }\r\n\r\n // Remove the command name from args for the generator\r\n const generatorData: CommandActionData = {\r\n ...data,\r\n args: data.args.slice(1),\r\n };\r\n\r\n await generator(generatorData);\r\n}\r\n\r\n// Master generate command\r\nexport const generateCommand = command({\r\n name: \"generate <generator> [args...]\",\r\n alias: \"g\", // Allows 'warlock g module ...'\r\n description: \"Scaffold a new component\",\r\n action: generateCommandAction,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\n// Individual commands\r\nexport const generateModuleCommand = command({\r\n name: \"generate.module <name>\",\r\n alias: \"gen.m\",\r\n description: \"Generate a new module\",\r\n action: generateModule,\r\n options: [\r\n {\r\n text: \"--minimal, -m\",\r\n description:\r\n \"Generate a minimal skeleton (routes, main, locales, empty subfolders) instead of the full CRUD scaffold\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateControllerCommand = command({\r\n name: \"generate.controller <module>/<name>\",\r\n alias: \"gen.c\",\r\n description: \"Generate a new controller\",\r\n action: generateController,\r\n options: [\r\n {\r\n text: \"--with-validation, -v\",\r\n description: \"Generate a validation schema and bind it to the controller\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateServiceCommand = command({\r\n name: \"generate.service <module>/<name>\",\r\n alias: \"gen.s\",\r\n description: \"Generate a new service\",\r\n action: generateService,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateModelCommand = command({\r\n name: \"generate.model <module>/<name>\",\r\n alias: \"gen.md\",\r\n description: \"Generate a new model with migration\",\r\n action: generateModel,\r\n options: [\r\n {\r\n text: \"--with-resource, -rs\",\r\n description: \"Generate resource\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--table <name>\",\r\n description: \"Specify table name\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--timestamps [bool]\",\r\n description: \"Include timestamps in migration (default: true)\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateRepositoryCommand = command({\r\n name: \"generate.repository <module>/<name>\",\r\n alias: \"gen.r\",\r\n description: \"Generate a new repository\",\r\n action: generateRepository,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateResourceCommand = command({\r\n name: \"generate.resource <module>/<name>\",\r\n alias: \"gen.rs\",\r\n description: \"Generate a new resource\",\r\n action: generateResource,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateMigrationCommand = command({\r\n name: \"generate.migration <model-path>\",\r\n alias: \"gen.mig\",\r\n description: \"Generate a new migration for a model\",\r\n action: generateMigration,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--add <columns>\",\r\n description: \"Columns to add (DSL: name:type:modifier,...)\",\r\n },\r\n {\r\n text: \"--drop <columns>\",\r\n description: \"Columns to drop (comma-separated names)\",\r\n },\r\n {\r\n text: \"--rename <columns>\",\r\n description: \"Columns to rename (DSL: old:new,...)\",\r\n },\r\n {\r\n text: \"--timestamps [bool]\",\r\n description: \"Include timestamps (default: true)\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,aAAyE;CAC7E,QAAQ;CACR,YAAY;CACZ,SAAS;CACT,OAAO;CACP,WAAW;CACX,YAAY;CACZ,UAAU;AACZ;AAEA,eAAe,sBAAs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GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC;AAED,MAAa,yBAAyB,QAAQ;CAC5C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC;AAED,MAAa,uBAAuB,QAAQ;CAC1C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC;AAED,MAAa,4BAA4B,QAAQ;CAC/C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC;AAED,MAAa,0BAA0B,QAAQ;CAC7C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC;AAED,MAAa,2BAA2B,QAAQ;CAC9C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/controller.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport type { CommandActionData } from \"
|
|
1
|
+
{"version":3,"file":"controller.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/controller.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { controllerStub, schemaStub } from \"../templates/stubs\";\r\nimport { parseModulePath, parseName } from \"../utils/name-parser\";\r\nimport {\r\n componentExists,\r\n ensureComponentDirectory,\r\n moduleExists,\r\n resolveComponentPath,\r\n} from \"../utils/path-resolver\";\r\nimport { putFileAsync, setDryRun } from \"../utils/writer\";\r\n\r\nexport async function generateController(data: CommandActionData): Promise<void> {\r\n const input = data.args[0];\r\n\r\n if (!input) {\r\n console.log(colors.red(\"Error: Controller name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.controller <module>/<name>\"));\r\n console.log(colors.yellow(\"Example: warlock create.controller users/create-user\"));\r\n process.exit(1);\r\n }\r\n\r\n const { module, name: componentName } = parseModulePath(input);\r\n\r\n if (!module) {\r\n console.log(colors.red(\"Error: Module name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.controller <module>/<name>\"));\r\n process.exit(1);\r\n }\r\n\r\n // Check if module exists\r\n if (!(await moduleExists(module))) {\r\n console.log(colors.red(`Error: Module \"${module}\" does not exist`));\r\n console.log(colors.yellow(`Run: warlock create.module ${module}`));\r\n process.exit(1);\r\n }\r\n\r\n const name = parseName(componentName);\r\n const withValidation = data.options.withValidation || data.options.v;\r\n const force = data.options.force || data.options.f;\r\n setDryRun(Boolean(data.options.dryRun));\r\n\r\n // Check if controller already exists\r\n const controllerPath = resolveComponentPath(module, \"controllers\", `${name.kebab}.controller`);\r\n if ((await componentExists(module, \"controllers\", `${name.kebab}.controller`)) && !force) {\r\n console.log(colors.red(`Error: Controller \"${name.kebab}.controller.ts\" already exists`));\r\n console.log(colors.yellow(\"Use --force to overwrite\"));\r\n process.exit(1);\r\n }\r\n\r\n // Ensure directories exist\r\n await ensureComponentDirectory(module, \"controllers\");\r\n\r\n // Generate controller\r\n const controllerContent = controllerStub(name, { withValidation: !!withValidation });\r\n await putFileAsync(controllerPath, controllerContent);\r\n\r\n // Generate the validation schema alongside the controller if requested.\r\n // The controller imports the schema's exported type + value directly —\r\n // there is no separate `requests/` alias file.\r\n if (withValidation) {\r\n await ensureComponentDirectory(module, \"schema\");\r\n\r\n const schemaPath = resolveComponentPath(module, \"schema\", `${name.kebab}.schema`);\r\n const schemaContent = schemaStub(name);\r\n\r\n await putFileAsync(schemaPath, schemaContent);\r\n }\r\n\r\n console.log(colors.cyan(`\\n✨ Controller \"${name.camel}\" generated successfully!`));\r\n}\r\n"],"mappings":";;;;;;;AAYA,eAAsB,mBAAmB,MAAwC;CAC/E,MAAM,QAAQ,KAAK,KAAK;CAExB,IAAI,CAAC,OAAO;EACV,QAAQ,IAAI,OAAO,IAAI,oCAAoC,CAAC;EAC5D,QAAQ,IAAI,OAAO,OAAO,kDAAkD,CAAC;EAC7E,QAAQ,IAAI,OAAO,OAAO,sDAAsD,CAAC;EACjF,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,EAAE,QAAQ,MAAM,kBAAkB,gBAAgB,KAAK;CAE7D,IAAI,CAAC,QAAQ;EACX,QAAQ,IAAI,OAAO,IAAI,gCAAgC,CAAC;EACxD,QAAQ,IAAI,OAAO,OAAO,kDAAkD,CAAC;EAC7E,QAAQ,KAAK,CAAC;CAChB;CAGA,IAAI,CAAE,MAAM,aAAa,MAAM,GAAI;EACjC,QAAQ,IAAI,OAAO,IAAI,kBAAkB,OAAO,iBAAiB,CAAC;EAClE,QAAQ,IAAI,OAAO,OAAO,8BAA8B,QAAQ,CAAC;EACjE,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,OAAO,UAAU,aAAa;CACpC,MAAM,iBAAiB,KAAK,QAAQ,kBAAkB,KAAK,QAAQ;CACnE,MAAM,QAAQ,KAAK,QAAQ,SAAS,KAAK,QAAQ;CACjD,UAAU,QAAQ,KAAK,QAAQ,MAAM,CAAC;CAGtC,MAAM,iBAAiB,qBAAqB,QAAQ,eAAe,GAAG,KAAK,MAAM,YAAY;CAC7F,IAAK,MAAM,gBAAgB,QAAQ,eAAe,GAAG,KAAK,MAAM,YAAY,KAAM,CAAC,OAAO;EACxF,QAAQ,IAAI,OAAO,IAAI,sBAAsB,KAAK,MAAM,+BAA+B,CAAC;EACxF,QAAQ,IAAI,OAAO,OAAO,0BAA0B,CAAC;EACrD,QAAQ,KAAK,CAAC;CAChB;CAGA,MAAM,yBAAyB,QAAQ,aAAa;CAIpD,MAAM,aAAa,gBADO,eAAe,MAAM,EAAE,gBAAgB,CAAC,CAAC,eAAe,CAC/B,CAAC;CAKpD,IAAI,gBAAgB;EAClB,MAAM,yBAAyB,QAAQ,QAAQ;EAK/C,MAAM,aAHa,qBAAqB,QAAQ,UAAU,GAAG,KAAK,MAAM,QAG5C,GAFN,WAAW,IAEU,CAAC;CAC9C;CAEA,QAAQ,IAAI,OAAO,KAAK,qBAAqB,KAAK,MAAM,0BAA0B,CAAC;AACrF"}
|
|
@@ -4,8 +4,8 @@ import { migrationAlterStub, migrationStub } from "../templates/stubs.mjs";
|
|
|
4
4
|
import { parseName } from "../utils/name-parser.mjs";
|
|
5
5
|
import { ensureDirectoryAsync, putFileAsync, setDryRun } from "../utils/writer.mjs";
|
|
6
6
|
import { parseColumnDsl } from "./column-dsl-parser.mjs";
|
|
7
|
-
import { colors } from "@mongez/copper";
|
|
8
7
|
import path from "node:path";
|
|
8
|
+
import { colors } from "@mongez/copper";
|
|
9
9
|
|
|
10
10
|
//#region ../core/src/cli/commands/generate/generators/migration.generator.ts
|
|
11
11
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/migration.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport { appPath } from \"../../../../utils\";\r\nimport type { CommandActionData } from \"
|
|
1
|
+
{"version":3,"file":"migration.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/migration.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport { appPath } from \"../../../../utils\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { migrationAlterStub, migrationStub } from \"../templates/stubs\";\r\nimport { parseColumnDsl } from \"./column-dsl-parser\";\r\nimport { parseName } from \"../utils/name-parser\";\r\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\r\n\r\n/**\r\n * Generate a migration file for a model\r\n */\r\n/**\r\n * Create a migration file for a model\r\n */\r\nexport async function createMigrationFile(moduleName: string, entityName: string, options: any = {}) {\r\n const entity = parseName(entityName);\r\n\r\n // Generate timestamp: MM-DD-YYYY_HH-MM-SS\r\n const now = new Date();\r\n const timestamp = `${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}-${now.getFullYear()}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\r\n\r\n const migrationFileName = `${timestamp}-${entity.kebab}.migration.ts`;\r\n const migrationsPath = path.join(appPath(), moduleName, \"models\", entity.kebab, \"migrations\");\r\n\r\n // Ensure migrations directory exists\r\n await ensureDirectoryAsync(migrationsPath);\r\n\r\n const addParams = options.add as string;\r\n const dropParams = options.drop as string;\r\n const renameParams = options.rename as string;\r\n const timestamps = options.timestamps !== \"false\" && options.timestamps !== false;\r\n\r\n let migrationContent = \"\";\r\n\r\n if (addParams || dropParams || renameParams) {\r\n // Generate alter stub\r\n const parsedAdd = parseColumnDsl(addParams || \"\");\r\n const helpersSet = new Set<string>();\r\n \r\n const addLines = parsedAdd.map((col) => {\r\n helpersSet.add(col.helper);\r\n return ` ${col.name}: ${col.helper}()${col.modifiers.join(\"\")},`;\r\n });\r\n\r\n let formattedDrop: string | undefined = undefined;\r\n if (dropParams) {\r\n formattedDrop = JSON.stringify(dropParams.split(\",\").map((s) => s.trim()));\r\n }\r\n\r\n let formattedRename: string | undefined = undefined;\r\n if (renameParams) {\r\n const obj: Record<string, string> = {};\r\n renameParams.split(\",\").map((s) => s.trim()).forEach((p) => {\r\n const [oldN, newN] = p.split(\":\").map((s) => s.trim());\r\n if (oldN && newN) obj[oldN] = newN;\r\n });\r\n formattedRename = JSON.stringify(obj, null, 2).replace(/\\n/g, '\\n ');\r\n }\r\n\r\n migrationContent = migrationAlterStub(entity, {\r\n add: addLines.length > 0 ? addLines.join(\"\\n\") : undefined,\r\n drop: formattedDrop,\r\n rename: formattedRename,\r\n imports: Array.from(helpersSet),\r\n });\r\n } else {\r\n // Generate create stub\r\n migrationContent = migrationStub(entity, {\r\n timestamps,\r\n });\r\n }\r\n\r\n // Create migration file\r\n const migrationFilePath = path.join(migrationsPath, migrationFileName);\r\n await putFileAsync(migrationFilePath, migrationContent);\r\n\r\n return migrationFilePath;\r\n}\r\n\r\n/**\r\n * Generate a migration file for a model\r\n */\r\nexport async function generateMigration(data: CommandActionData) {\r\n const modelPath = data.args[0] as string;\r\n\r\n if (!modelPath) {\r\n console.log(colors.red(\"Error: Model path is required\"));\r\n console.log(colors.gray(\"Usage: warlock gen.migration <model-path>\"));\r\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\r\n return;\r\n }\r\n\r\n // Parse model path (e.g., \"products/product\")\r\n const [moduleName, entityName] = modelPath.split(\"/\");\r\n\r\n if (!moduleName || !entityName) {\r\n console.log(colors.red(\"Error: Invalid model path format. Expected: <module>/<entity>\"));\r\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\r\n return;\r\n }\r\n\r\n setDryRun(Boolean(data.options.dryRun));\r\n\r\n const migrationFilePath = await createMigrationFile(moduleName, entityName, data.options);\r\n\r\n console.log(\r\n colors.cyan(`\\n✨ Migration file created at: ${path.relative(appPath(), migrationFilePath)}`),\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,eAAsB,oBAAoB,YAAoB,YAAoB,UAAe,CAAC,GAAG;CACnG,MAAM,SAAS,UAAU,UAAU;CAGnC,MAAM,sBAAM,IAAI,KAAK;CAGrB,MAAM,oBAAoB,GAAG,GAFR,OAAO,IAAI,SAAS,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,GAAG,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,IAE5N,GAAG,OAAO,MAAM;CACvD,MAAM,iBAAiB,KAAK,KAAK,QAAQ,GAAG,YAAY,UAAU,OAAO,OAAO,YAAY;CAG5F,MAAM,qBAAqB,cAAc;CAEzC,MAAM,YAAY,QAAQ;CAC1B,MAAM,aAAa,QAAQ;CAC3B,MAAM,eAAe,QAAQ;CAC7B,MAAM,aAAa,QAAQ,eAAe,WAAW,QAAQ,eAAe;CAE5E,IAAI,mBAAmB;CAEvB,IAAI,aAAa,cAAc,cAAc;EAE3C,MAAM,YAAY,eAAe,aAAa,EAAE;EAChD,MAAM,6BAAa,IAAI,IAAY;EAEnC,MAAM,WAAW,UAAU,KAAK,QAAQ;GACtC,WAAW,IAAI,IAAI,MAAM;GACzB,OAAO,OAAO,IAAI,KAAK,IA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CAAC;EACvF,QAAQ,IAAI,OAAO,KAAK,iDAAiD,CAAC;EAC1E;CACF;CAEA,UAAU,QAAQ,KAAK,QAAQ,MAAM,CAAC;CAEtC,MAAM,oBAAoB,MAAM,oBAAoB,YAAY,YAAY,KAAK,OAAO;CAExF,QAAQ,IACN,OAAO,KAAK,oCAAoC,KAAK,SAAS,QAAQ,GAAG,iBAAiB,GAAG,CAC/F;AACF"}
|
|
@@ -2,8 +2,8 @@ import { migrationStub, modelStub } from "../templates/stubs.mjs";
|
|
|
2
2
|
import { parseModulePath, singularName } from "../utils/name-parser.mjs";
|
|
3
3
|
import { ensureDirectoryAsync, putFileAsync, setDryRun } from "../utils/writer.mjs";
|
|
4
4
|
import { componentExists, moduleExists, resolveModulePath } from "../utils/path-resolver.mjs";
|
|
5
|
-
import { colors } from "@mongez/copper";
|
|
6
5
|
import path from "node:path";
|
|
6
|
+
import { colors } from "@mongez/copper";
|
|
7
7
|
|
|
8
8
|
//#region ../core/src/cli/commands/generate/generators/model.generator.ts
|
|
9
9
|
async function generateModel(data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/model.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport type { CommandActionData } from \"
|
|
1
|
+
{"version":3,"file":"model.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/model.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { migrationStub, modelStub } from \"../templates/stubs\";\r\nimport { parseModulePath, singularName } from \"../utils/name-parser\";\r\nimport { componentExists, moduleExists, resolveModulePath } from \"../utils/path-resolver\";\r\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\r\n\r\nexport async function generateModel(data: CommandActionData): Promise<void> {\r\n const input = data.args[0];\r\n\r\n if (!input) {\r\n console.log(colors.red(\"Error: Model name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.model <module>/<name>\"));\r\n console.log(colors.yellow(\"Example: warlock create.model users/user\"));\r\n process.exit(1);\r\n }\r\n\r\n const { module, name: componentName } = parseModulePath(input);\r\n\r\n if (!module) {\r\n console.log(colors.red(\"Error: Module name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.model <module>/<name>\"));\r\n process.exit(1);\r\n }\r\n\r\n // Check if module exists\r\n if (!(await moduleExists(module))) {\r\n console.log(colors.red(`Error: Module \"${module}\" does not exist`));\r\n console.log(colors.yellow(`Run: warlock create.module ${module}`));\r\n process.exit(1);\r\n }\r\n\r\n const name = singularName(componentName);\r\n const force = data.options.force || data.options.f;\r\n setDryRun(Boolean(data.options.dryRun));\r\n const withResource = data.options.withResource || data.options.rs;\r\n const tableName = (data.options.table as string) || name.plural.snake;\r\n\r\n // Check if model already exists\r\n const modelDir = path.join(resolveModulePath(module), \"models\", name.kebab);\r\n const modelPath = path.join(modelDir, `${name.kebab}.model.ts`);\r\n\r\n if ((await componentExists(module, `models/${name.kebab}`, `${name.kebab}.model`)) && !force) {\r\n console.log(colors.red(`Error: Model \"${name.kebab}\" already exists`));\r\n console.log(colors.yellow(\"Use --force to overwrite\"));\r\n process.exit(1);\r\n }\r\n\r\n // Ensure directories exist\r\n await ensureDirectoryAsync(modelDir);\r\n await ensureDirectoryAsync(path.join(modelDir, \"migrations\"));\r\n\r\n // Generate model\r\n const modelContent = modelStub(name, { tableName, withResource: !!withResource });\r\n await putFileAsync(modelPath, modelContent);\r\n\r\n // Generate index.ts\r\n const indexContent = `export * from \"./${name.kebab}.model\";\r\n`;\r\n await putFileAsync(path.join(modelDir, \"index.ts\"), indexContent);\r\n\r\n // Generate migration\r\n const timestamp = new Date().toISOString().replace(/[-:T]/g, \"_\").split(\".\")[0];\r\n const migrationPath = path.join(\r\n modelDir,\r\n \"migrations\",\r\n `${timestamp}_${name.kebab}.migration.ts`,\r\n );\r\n\r\n const migrationContent = migrationStub(name, {\r\n timestamps: data.options.timestamps !== \"false\" && data.options.timestamps !== false,\r\n });\r\n\r\n await putFileAsync(migrationPath, migrationContent);\r\n\r\n console.log(colors.cyan(`\\n✨ Model \"${name.pascal}\" generated successfully!`));\r\n console.log(colors.gray(`\\nNext steps:`));\r\n console.log(colors.gray(` 1. Update model schema in ${name.kebab}.model.ts`));\r\n console.log(\r\n colors.gray(` 2. Update migration in migrations/${timestamp}_${name.kebab}.migration.ts`),\r\n );\r\n console.log(colors.gray(` 3. Run migration: warlock migrate`));\r\n}\r\n"],"mappings":";;;;;;;;AAQA,eAAsB,cAAc,MAAwC;CAC1E,MAAM,QAAQ,KAAK,KAAK;CAExB,IAAI,CAAC,OAAO;EACV,QAAQ,IAAI,OAAO,IAAI,+BAA+B,CAAC;EACvD,QAAQ,IAAI,OAAO,OAAO,6CAA6C,CAAC;EACxE,QAAQ,IAAI,OAAO,OAAO,0CAA0C,CAAC;EACrE,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,EAAE,QAAQ,MAAM,kBAAkB,gBAAgB,KAAK;CAE7D,IAAI,CAAC,QAAQ;EACX,QAAQ,IAAI,OAAO,IAAI,gCAAgC,CAAC;EACxD,QAAQ,IAAI,OAAO,OAAO,6CAA6C,CAAC;EACxE,QAAQ,KAAK,CAAC;CAChB;CAGA,IAAI,CAAE,MAAM,aAAa,MAAM,GAAI;EACjC,QAAQ,IAAI,OAAO,IAAI,kBAAkB,OAAO,iBAAiB,CAAC;EAClE,QAAQ,IAAI,OAAO,OAAO,8BAA8B,QAAQ,CAAC;EACjE,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,OAAO,aAAa,aAAa;CACvC,MAAM,QAAQ,KAAK,QAAQ,SAAS,KAAK,QAAQ;CACjD,UAAU,QAAQ,KAAK,QAAQ,MAAM,CAAC;CACtC,MAAM,eAAe,KAAK,QAAQ,gBAAgB,KAAK,QAAQ;CAC/D,MA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OAAO,KAAK,qCAAqC,CAAC;AAChE"}
|
|
@@ -5,8 +5,8 @@ import { pluralName, singularName } from "../utils/name-parser.mjs";
|
|
|
5
5
|
import { ensureDirectoryAsync, putFileAsync, setDryRun } from "../utils/writer.mjs";
|
|
6
6
|
import { moduleExists } from "../utils/path-resolver.mjs";
|
|
7
7
|
import { createMigrationFile } from "./migration.generator.mjs";
|
|
8
|
-
import { colors } from "@mongez/copper";
|
|
9
8
|
import path from "node:path";
|
|
9
|
+
import { colors } from "@mongez/copper";
|
|
10
10
|
|
|
11
11
|
//#region ../core/src/cli/commands/generate/generators/module.generator.ts
|
|
12
12
|
async function generateModule(data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/module.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport { appPath } from \"../../../../utils\";\r\nimport type { CommandActionData } from \"../../../types\";\r\nimport {\r\n crudCreateControllerStub,\r\n crudCreateSchemaStub,\r\n crudCreateServiceStub,\r\n crudDeleteControllerStub,\r\n crudDeleteServiceStub,\r\n crudGetServiceStub,\r\n crudListControllerStub,\r\n crudListServiceStub,\r\n crudModelStub,\r\n crudRepositoryStub,\r\n crudResourceStub,\r\n crudRoutesStub,\r\n crudSeedStub,\r\n crudShowControllerStub,\r\n crudUpdateControllerStub,\r\n crudUpdateSchemaStub,\r\n crudUpdateServiceStub,\r\n} from \"../templates/stubs\";\r\nimport { pluralName, singularName } from \"../utils/name-parser\";\r\nimport { moduleExists } from \"../utils/path-resolver\";\r\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\r\nimport { createMigrationFile } from \"./migration.generator\";\r\n\r\nexport async function generateModule(data: CommandActionData): Promise<void> {\r\n const moduleName = data.args[0];\r\n\r\n if (!moduleName) {\r\n console.log(colors.red(\"Error: Module name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock generate.module <name> [options]\"));\r\n console.log(colors.yellow(\"Example: warlock generate.module products\"));\r\n console.log(colors.yellow(\" warlock generate.module products --minimal\"));\r\n process.exit(1);\r\n }\r\n\r\n const name = pluralName(moduleName);\r\n const force = data.options.force || data.options.f;\r\n setDryRun(Boolean(data.options.dryRun));\r\n\r\n // Full CRUD is the default; --minimal (-m) opts down to a bare skeleton.\r\n const minimal = data.options.minimal || data.options.m;\r\n const withCrud = !minimal;\r\n\r\n // Check if module already exists\r\n if ((await moduleExists(name.kebab)) && !force) {\r\n console.log(colors.red(`Error: Module \"${name.kebab}\" already exists`));\r\n console.log(colors.yellow(\"Use --force to overwrite\"));\r\n process.exit(1);\r\n }\r\n\r\n const modulePath = appPath(name.kebab);\r\n\r\n // Create module directory structure\r\n const directories = [\r\n \"controllers\",\r\n \"services\",\r\n \"models\",\r\n \"repositories\",\r\n \"schema\",\r\n \"resources\",\r\n \"events\",\r\n \"types\",\r\n \"utils\",\r\n ];\r\n\r\n for (const dir of directories) {\r\n await ensureDirectoryAsync(path.join(modulePath, dir));\r\n }\r\n\r\n // Create main.ts\r\n const mainContent = `// You may use this file as a custom entry point to be executed when the app starts.\r\n// it runs only once, and you don't need to import the routes.ts file, it will be imported automatically.\r\n// Use it to regsiter or boot up any custom logic for this module.\r\n`;\r\n await putFileAsync(path.join(modulePath, \"main.ts\"), mainContent);\r\n\r\n // Create routes.ts\r\n const routesContent = withCrud\r\n ? crudRoutesStub(name)\r\n : `import { router } from \"@warlock.js/core\";\r\nimport { guarded } from \"app/shared/utils/router\";\r\n\r\n// Define your routes here\r\n// Example:\r\n// router.get(\"/${name.kebab}\", listController);\r\n`;\r\n await putFileAsync(path.join(modulePath, \"routes.ts\"), routesContent);\r\n\r\n // Create utils/locales.ts\r\n const localesContent = `import { groupedTranslations } from \"@warlock.js/core\";\r\n\r\ngroupedTranslations(\"${name.camel}\", {\r\n // Add your translations here\r\n // Example:\r\n // welcome: {\r\n // en: \"Welcome\",\r\n // ar: \"Ù…Ø±ØØ¨Ø§\",\r\n // },\r\n});\r\n`;\r\n await putFileAsync(path.join(modulePath, \"utils\", \"locales.ts\"), localesContent);\r\n\r\n // Full CRUD scaffold (the default) unless --minimal was passed\r\n if (withCrud) {\r\n const entity = singularName(moduleName);\r\n\r\n // Create controllers\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `create-${entity.kebab}.controller.ts`),\r\n crudCreateControllerStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `update-${entity.kebab}.controller.ts`),\r\n crudUpdateControllerStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `list-${name.kebab}.controller.ts`),\r\n crudListControllerStub(name),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `get-${entity.kebab}.controller.ts`),\r\n crudShowControllerStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `delete-${entity.kebab}.controller.ts`),\r\n crudDeleteControllerStub(entity),\r\n );\r\n\r\n // Create schema files — each exports both the schema value and its\r\n // inferred type; controllers import them directly (no requests/ alias).\r\n await putFileAsync(\r\n path.join(modulePath, \"schema\", `create-${entity.kebab}.schema.ts`),\r\n crudCreateSchemaStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"schema\", `update-${entity.kebab}.schema.ts`),\r\n crudUpdateSchemaStub(entity),\r\n );\r\n\r\n // Create model\r\n await ensureDirectoryAsync(path.join(modulePath, \"models\", entity.kebab));\r\n await putFileAsync(\r\n path.join(modulePath, \"models\", entity.kebab, `${entity.kebab}.model.ts`),\r\n crudModelStub(entity),\r\n );\r\n\r\n // Create model index\r\n await putFileAsync(\r\n path.join(modulePath, \"models\", entity.kebab, \"index.ts\"),\r\n `export * from \"./${entity.kebab}.model\";\\n`,\r\n );\r\n\r\n // Create migrations folder\r\n await ensureDirectoryAsync(path.join(modulePath, \"models\", entity.kebab, \"migrations\"));\r\n\r\n // Create resource\r\n await putFileAsync(\r\n path.join(modulePath, \"resources\", `${entity.kebab}.resource.ts`),\r\n crudResourceStub(name),\r\n );\r\n\r\n // Create repository\r\n await putFileAsync(\r\n path.join(modulePath, \"repositories\", `${name.kebab}.repository.ts`),\r\n crudRepositoryStub(name),\r\n );\r\n\r\n // Create services\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `create-${entity.kebab}.service.ts`),\r\n crudCreateServiceStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `update-${entity.kebab}.service.ts`),\r\n crudUpdateServiceStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `list-${name.kebab}.service.ts`),\r\n crudListServiceStub(name),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `get-${entity.kebab}.service.ts`),\r\n crudGetServiceStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `delete-${entity.kebab}.service.ts`),\r\n crudDeleteServiceStub(entity),\r\n );\r\n\r\n // Create seeds\r\n await ensureDirectoryAsync(path.join(modulePath, \"seeds\"));\r\n await putFileAsync(path.join(modulePath, \"seeds\", `${name.kebab}.seed.ts`), crudSeedStub(name));\r\n\r\n // Create migration\r\n await createMigrationFile(name.kebab, entity.kebab);\r\n }\r\n\r\n console.log(colors.cyan(`\\n✨ Module \"${name.kebab}\" generated successfully!`));\r\n\r\n if (withCrud) {\r\n console.log(colors.gray(`\\n📦 CRUD scaffold created with:`));\r\n console.log(colors.gray(` - List, Get, Create, Update & Delete controllers`));\r\n console.log(colors.gray(` - Repository`));\r\n console.log(colors.gray(` - Validation schemas in schema/`));\r\n console.log(colors.gray(` - Model with resource`));\r\n console.log(colors.gray(` - Routes configured`));\r\n console.log(colors.gray(`\\nNext steps:`));\r\n console.log(\r\n colors.gray(` 1. Update model schema in models/${name.kebab}/${name.kebab}.model.ts`),\r\n );\r\n console.log(colors.gray(` 2. Update schema rules in schema/*.schema.ts`));\r\n console.log(\r\n colors.gray(` 3. Create migration: warlock generate.model ${name.kebab}/${name.kebab}`),\r\n );\r\n } else {\r\n console.log(colors.gray(`\\nNext steps:`));\r\n console.log(colors.gray(` 1. Define routes in ${name.kebab}/routes.ts`));\r\n console.log(\r\n colors.gray(` 2. Create controllers: warlock generate.controller ${name.kebab}/<name>`),\r\n );\r\n console.log(colors.gray(` 3. Create models: warlock generate.model ${name.kebab}/<name>`));\r\n console.log(colors.gray(`\\nTip: omit --minimal to generate a full CRUD scaffold`));\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AA4BA,eAAsB,eAAe,MAAwC;CAC3E,MAAM,aAAa,KAAK,KAAK;CAE7B,IAAI,CAAC,YAAY;EACf,QAAQ,IAAI,OAAO,IAAI,gCAAgC,CAAC;EACxD,QAAQ,IAAI,OAAO,OAAO,iDAAiD,CAAC;EAC5E,QAAQ,IAAI,OAAO,OAAO,2CAA2C,CAAC;EACtE,QAAQ,IAAI,OAAO,OAAO,qDAAqD,CAAC;EAChF,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,OAAO,WAAW,UAAU;CAClC,MAAM,QAAQ,KAAK,QAAQ,SAAS,KAAK,QAAQ;CACjD,UAAU,QAAQ,KAAK,QAAQ,MAAM,CAAC;CAItC,MAAM,WAAW,EADD,KAAK,QAAQ,WAAW,KAAK,QAAQ;CAIrD,IAAK,MAAM,aAAa,KAAK,KAAK,KAAM,CAAC,OAAO;EAC9C,QAAQ,IAAI,OAAO,IAAI,kBAAkB,KAAK,MAAM,iBAAiB,CAAC;EACtE,QAAQ,IAAI,OAAO,OAAO,0BAA0B,CAAC;EACrD,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,aAAa,QAAQ,KAAK,KAAK;CAerC,KAAK,MAAM,OAAO;EAXhB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAG0B,GAC1B,MAAM,qBAAqB,KAAK,KAAK,YAAY,GAAG,CAAC;CAQvD,MAAM,aAAa,KAA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BAAyB,CAAC;EAClD,QAAQ,IAAI,OAAO,KAAK,uBAAuB,CAAC;EAChD,QAAQ,IAAI,OAAO,KAAK,eAAe,CAAC;EACxC,QAAQ,IACN,OAAO,KAAK,sCAAsC,KAAK,MAAM,GAAG,KAAK,MAAM,UAAU,CACvF;EACA,QAAQ,IAAI,OAAO,KAAK,gDAAgD,CAAC;EACzE,QAAQ,IACN,OAAO,KAAK,iDAAiD,KAAK,MAAM,GAAG,KAAK,OAAO,CACzF;CACF,OAAO;EACL,QAAQ,IAAI,OAAO,KAAK,eAAe,CAAC;EACxC,QAAQ,IAAI,OAAO,KAAK,yBAAyB,KAAK,MAAM,WAAW,CAAC;EACxE,QAAQ,IACN,OAAO,KAAK,wDAAwD,KAAK,MAAM,QAAQ,CACzF;EACA,QAAQ,IAAI,OAAO,KAAK,8CAA8C,KAAK,MAAM,QAAQ,CAAC;EAC1F,QAAQ,IAAI,OAAO,KAAK,wDAAwD,CAAC;CACnF;AACF"}
|
|
1
|
+
{"version":3,"file":"module.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/module.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport { appPath } from \"../../../../utils\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport {\r\n crudCreateControllerStub,\r\n crudCreateSchemaStub,\r\n crudCreateServiceStub,\r\n crudDeleteControllerStub,\r\n crudDeleteServiceStub,\r\n crudGetServiceStub,\r\n crudListControllerStub,\r\n crudListServiceStub,\r\n crudModelStub,\r\n crudRepositoryStub,\r\n crudResourceStub,\r\n crudRoutesStub,\r\n crudSeedStub,\r\n crudShowControllerStub,\r\n crudUpdateControllerStub,\r\n crudUpdateSchemaStub,\r\n crudUpdateServiceStub,\r\n} from \"../templates/stubs\";\r\nimport { pluralName, singularName } from \"../utils/name-parser\";\r\nimport { moduleExists } from \"../utils/path-resolver\";\r\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\r\nimport { createMigrationFile } from \"./migration.generator\";\r\n\r\nexport async function generateModule(data: CommandActionData): Promise<void> {\r\n const moduleName = data.args[0];\r\n\r\n if (!moduleName) {\r\n console.log(colors.red(\"Error: Module name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock generate.module <name> [options]\"));\r\n console.log(colors.yellow(\"Example: warlock generate.module products\"));\r\n console.log(colors.yellow(\" warlock generate.module products --minimal\"));\r\n process.exit(1);\r\n }\r\n\r\n const name = pluralName(moduleName);\r\n const force = data.options.force || data.options.f;\r\n setDryRun(Boolean(data.options.dryRun));\r\n\r\n // Full CRUD is the default; --minimal (-m) opts down to a bare skeleton.\r\n const minimal = data.options.minimal || data.options.m;\r\n const withCrud = !minimal;\r\n\r\n // Check if module already exists\r\n if ((await moduleExists(name.kebab)) && !force) {\r\n console.log(colors.red(`Error: Module \"${name.kebab}\" already exists`));\r\n console.log(colors.yellow(\"Use --force to overwrite\"));\r\n process.exit(1);\r\n }\r\n\r\n const modulePath = appPath(name.kebab);\r\n\r\n // Create module directory structure\r\n const directories = [\r\n \"controllers\",\r\n \"services\",\r\n \"models\",\r\n \"repositories\",\r\n \"schema\",\r\n \"resources\",\r\n \"events\",\r\n \"types\",\r\n \"utils\",\r\n ];\r\n\r\n for (const dir of directories) {\r\n await ensureDirectoryAsync(path.join(modulePath, dir));\r\n }\r\n\r\n // Create main.ts\r\n const mainContent = `// You may use this file as a custom entry point to be executed when the app starts.\r\n// it runs only once, and you don't need to import the routes.ts file, it will be imported automatically.\r\n// Use it to regsiter or boot up any custom logic for this module.\r\n`;\r\n await putFileAsync(path.join(modulePath, \"main.ts\"), mainContent);\r\n\r\n // Create routes.ts\r\n const routesContent = withCrud\r\n ? crudRoutesStub(name)\r\n : `import { router } from \"@warlock.js/core\";\r\nimport { guarded } from \"app/shared/utils/router\";\r\n\r\n// Define your routes here\r\n// Example:\r\n// router.get(\"/${name.kebab}\", listController);\r\n`;\r\n await putFileAsync(path.join(modulePath, \"routes.ts\"), routesContent);\r\n\r\n // Create utils/locales.ts\r\n const localesContent = `import { groupedTranslations } from \"@warlock.js/core\";\r\n\r\ngroupedTranslations(\"${name.camel}\", {\r\n // Add your translations here\r\n // Example:\r\n // welcome: {\r\n // en: \"Welcome\",\r\n // ar: \"Ù…Ø±ØØ¨Ø§\",\r\n // },\r\n});\r\n`;\r\n await putFileAsync(path.join(modulePath, \"utils\", \"locales.ts\"), localesContent);\r\n\r\n // Full CRUD scaffold (the default) unless --minimal was passed\r\n if (withCrud) {\r\n const entity = singularName(moduleName);\r\n\r\n // Create controllers\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `create-${entity.kebab}.controller.ts`),\r\n crudCreateControllerStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `update-${entity.kebab}.controller.ts`),\r\n crudUpdateControllerStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `list-${name.kebab}.controller.ts`),\r\n crudListControllerStub(name),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `get-${entity.kebab}.controller.ts`),\r\n crudShowControllerStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"controllers\", `delete-${entity.kebab}.controller.ts`),\r\n crudDeleteControllerStub(entity),\r\n );\r\n\r\n // Create schema files — each exports both the schema value and its\r\n // inferred type; controllers import them directly (no requests/ alias).\r\n await putFileAsync(\r\n path.join(modulePath, \"schema\", `create-${entity.kebab}.schema.ts`),\r\n crudCreateSchemaStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"schema\", `update-${entity.kebab}.schema.ts`),\r\n crudUpdateSchemaStub(entity),\r\n );\r\n\r\n // Create model\r\n await ensureDirectoryAsync(path.join(modulePath, \"models\", entity.kebab));\r\n await putFileAsync(\r\n path.join(modulePath, \"models\", entity.kebab, `${entity.kebab}.model.ts`),\r\n crudModelStub(entity),\r\n );\r\n\r\n // Create model index\r\n await putFileAsync(\r\n path.join(modulePath, \"models\", entity.kebab, \"index.ts\"),\r\n `export * from \"./${entity.kebab}.model\";\\n`,\r\n );\r\n\r\n // Create migrations folder\r\n await ensureDirectoryAsync(path.join(modulePath, \"models\", entity.kebab, \"migrations\"));\r\n\r\n // Create resource\r\n await putFileAsync(\r\n path.join(modulePath, \"resources\", `${entity.kebab}.resource.ts`),\r\n crudResourceStub(name),\r\n );\r\n\r\n // Create repository\r\n await putFileAsync(\r\n path.join(modulePath, \"repositories\", `${name.kebab}.repository.ts`),\r\n crudRepositoryStub(name),\r\n );\r\n\r\n // Create services\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `create-${entity.kebab}.service.ts`),\r\n crudCreateServiceStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `update-${entity.kebab}.service.ts`),\r\n crudUpdateServiceStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `list-${name.kebab}.service.ts`),\r\n crudListServiceStub(name),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `get-${entity.kebab}.service.ts`),\r\n crudGetServiceStub(entity),\r\n );\r\n\r\n await putFileAsync(\r\n path.join(modulePath, \"services\", `delete-${entity.kebab}.service.ts`),\r\n crudDeleteServiceStub(entity),\r\n );\r\n\r\n // Create seeds\r\n await ensureDirectoryAsync(path.join(modulePath, \"seeds\"));\r\n await putFileAsync(path.join(modulePath, \"seeds\", `${name.kebab}.seed.ts`), crudSeedStub(name));\r\n\r\n // Create migration\r\n await createMigrationFile(name.kebab, entity.kebab);\r\n }\r\n\r\n console.log(colors.cyan(`\\n✨ Module \"${name.kebab}\" generated successfully!`));\r\n\r\n if (withCrud) {\r\n console.log(colors.gray(`\\n📦 CRUD scaffold created with:`));\r\n console.log(colors.gray(` - List, Get, Create, Update & Delete controllers`));\r\n console.log(colors.gray(` - Repository`));\r\n console.log(colors.gray(` - Validation schemas in schema/`));\r\n console.log(colors.gray(` - Model with resource`));\r\n console.log(colors.gray(` - Routes configured`));\r\n console.log(colors.gray(`\\nNext steps:`));\r\n console.log(\r\n colors.gray(` 1. Update model schema in models/${name.kebab}/${name.kebab}.model.ts`),\r\n );\r\n console.log(colors.gray(` 2. Update schema rules in schema/*.schema.ts`));\r\n console.log(\r\n colors.gray(` 3. Create migration: warlock generate.model ${name.kebab}/${name.kebab}`),\r\n );\r\n } else {\r\n console.log(colors.gray(`\\nNext steps:`));\r\n console.log(colors.gray(` 1. Define routes in ${name.kebab}/routes.ts`));\r\n console.log(\r\n colors.gray(` 2. Create controllers: warlock generate.controller ${name.kebab}/<name>`),\r\n );\r\n console.log(colors.gray(` 3. Create models: warlock generate.model ${name.kebab}/<name>`));\r\n console.log(colors.gray(`\\nTip: omit --minimal to generate a full CRUD scaffold`));\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AA4BA,eAAsB,eAAe,MAAwC;CAC3E,MAAM,aAAa,KAAK,KAAK;CAE7B,IAAI,CAAC,YAAY;EACf,QAAQ,IAAI,OAAO,IAAI,gCAAgC,CAAC;EACxD,QAAQ,IAAI,OAAO,OAAO,iDAAiD,CAAC;EAC5E,QAAQ,IAAI,OAAO,OAAO,2CAA2C,CAAC;EACtE,QAAQ,IAAI,OAAO,OAAO,qDAAqD,CAAC;EAChF,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,OAAO,WAAW,UAAU;CAClC,MAAM,QAAQ,KAAK,QAAQ,SAAS,KAAK,QAAQ;CACjD,UAAU,QAAQ,KAAK,QAAQ,MAAM,CAAC;CAItC,MAAM,WAAW,EADD,KAAK,QAAQ,WAAW,KAAK,QAAQ;CAIrD,IAAK,MAAM,aAAa,KAAK,KAAK,KAAM,CAAC,OAAO;EAC9C,QAAQ,IAAI,OAAO,IAAI,kBAAkB,KAAK,MAAM,iBAAiB,CAAC;EACtE,QAAQ,IAAI,OAAO,OAAO,0BAA0B,CAAC;EACrD,QAAQ,KAAK,CAAC;CAChB;CAEA,M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C,CAAC;EAC7D,QAAQ,IAAI,OAAO,KAAK,oDAAoD,CAAC;EAC7E,QAAQ,IAAI,OAAO,KAAK,gBAAgB,CAAC;EACzC,QAAQ,IAAI,OAAO,KAAK,mCAAmC,CAAC;EAC5D,QAAQ,IAAI,OAAO,KAAK,yBAAyB,CAAC;EAClD,QAAQ,IAAI,OAAO,KAAK,uBAAuB,CAAC;EAChD,QAAQ,IAAI,OAAO,KAAK,eAAe,CAAC;EACxC,QAAQ,IACN,OAAO,KAAK,sCAAsC,KAAK,MAAM,GAAG,KAAK,MAAM,UAAU,CACvF;EACA,QAAQ,IAAI,OAAO,KAAK,gDAAgD,CAAC;EACzE,QAAQ,IACN,OAAO,KAAK,iDAAiD,KAAK,MAAM,GAAG,KAAK,OAAO,CACzF;CACF,OAAO;EACL,QAAQ,IAAI,OAAO,KAAK,eAAe,CAAC;EACxC,QAAQ,IAAI,OAAO,KAAK,yBAAyB,KAAK,MAAM,WAAW,CAAC;EACxE,QAAQ,IACN,OAAO,KAAK,wDAAwD,KAAK,MAAM,QAAQ,CACzF;EACA,QAAQ,IAAI,OAAO,KAAK,8CAA8C,KAAK,MAAM,QAAQ,CAAC;EAC1F,QAAQ,IAAI,OAAO,KAAK,wDAAwD,CAAC;CACnF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/repository.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport type { CommandActionData } from \"
|
|
1
|
+
{"version":3,"file":"repository.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/repository.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { repositoryStub } from \"../templates/stubs\";\r\nimport { putFileAsync, setDryRun } from \"../utils/writer\";\r\nimport { parseModulePath, parseName } from \"../utils/name-parser\";\r\nimport {\r\n componentExists,\r\n ensureComponentDirectory,\r\n moduleExists,\r\n resolveComponentPath,\r\n} from \"../utils/path-resolver\";\r\n\r\nexport async function generateRepository(data: CommandActionData): Promise<void> {\r\n const input = data.args[0];\r\n\r\n if (!input) {\r\n console.log(colors.red(\"Error: Repository name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.repository <module>/<name>\"));\r\n console.log(colors.yellow(\"Example: warlock create.repository users/user\"));\r\n process.exit(1);\r\n }\r\n\r\n const { module, name: componentName } = parseModulePath(input);\r\n\r\n if (!module) {\r\n console.log(colors.red(\"Error: Module name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.repository <module>/<name>\"));\r\n process.exit(1);\r\n }\r\n\r\n // Check if module exists\r\n if (!(await moduleExists(module))) {\r\n console.log(colors.red(`Error: Module \"${module}\" does not exist`));\r\n console.log(colors.yellow(`Run: warlock create.module ${module}`));\r\n process.exit(1);\r\n }\r\n\r\n const name = parseName(componentName);\r\n const force = data.options.force || data.options.f;\r\n setDryRun(Boolean(data.options.dryRun));\r\n\r\n // Check if repository already exists\r\n if ((await componentExists(module, \"repositories\", `${name.kebab}.repository`)) && !force) {\r\n console.log(colors.red(`Error: Repository \"${name.kebab}.repository.ts\" already exists`));\r\n console.log(colors.yellow(\"Use --force to overwrite\"));\r\n process.exit(1);\r\n }\r\n\r\n // Ensure directories exist\r\n await ensureComponentDirectory(module, \"repositories\");\r\n\r\n // Generate repository\r\n const repositoryPath = resolveComponentPath(module, \"repositories\", `${name.kebab}.repository`);\r\n const repositoryContent = repositoryStub(name);\r\n\r\n await putFileAsync(repositoryPath, repositoryContent);\r\n\r\n console.log(colors.cyan(`\\n✨ Repository \"${name.pascal}Repository\" generated successfully!`));\r\n}\r\n"],"mappings":";;;;;;;AAYA,eAAsB,mBAAmB,MAAwC;CAC/E,MAAM,QAAQ,KAAK,KAAK;CAExB,IAAI,CAAC,OAAO;EACV,QAAQ,IAAI,OAAO,IAAI,oCAAoC,CAAC;EAC5D,QAAQ,IAAI,OAAO,OAAO,kDAAkD,CAAC;EAC7E,QAAQ,IAAI,OAAO,OAAO,+CAA+C,CAAC;EAC1E,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,EAAE,QAAQ,MAAM,kBAAkB,gBAAgB,KAAK;CAE7D,IAAI,CAAC,QAAQ;EACX,QAAQ,IAAI,OAAO,IAAI,gCAAgC,CAAC;EACxD,QAAQ,IAAI,OAAO,OAAO,kDAAkD,CAAC;EAC7E,QAAQ,KAAK,CAAC;CAChB;CAGA,IAAI,CAAE,MAAM,aAAa,MAAM,GAAI;EACjC,QAAQ,IAAI,OAAO,IAAI,kBAAkB,OAAO,iBAAiB,CAAC;EAClE,QAAQ,IAAI,OAAO,OAAO,8BAA8B,QAAQ,CAAC;EACjE,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,OAAO,UAAU,aAAa;CACpC,MAAM,QAAQ,KAAK,QAAQ,SAAS,KAAK,QAAQ;CACjD,UAAU,QAAQ,KAAK,QAAQ,MAAM,CAAC;CAGtC,IAAK,MAAM,gBAAgB,QAAQ,gBAAgB,GAAG,KAAK,MAAM,YAAY,KAAM,CAAC,OAAO;EACzF,QAAQ,IAAI,OAAO,IAAI,sBAAsB,KAAK,MAAM,+BAA+B,CAAC;EACxF,QAAQ,IAAI,OAAO,OAAO,0BAA0B,CAAC;EACrD,QAAQ,KAAK,CAAC;CAChB;CAGA,MAAM,yBAAyB,QAAQ,cAAc;CAMrD,MAAM,aAHiB,qBAAqB,QAAQ,gBAAgB,GAAG,KAAK,MAAM,YAGlD,GAFN,eAAe,IAEU,CAAC;CAEpD,QAAQ,IAAI,OAAO,KAAK,qBAAqB,KAAK,OAAO,oCAAoC,CAAC;AAChG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/resource.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport type { CommandActionData } from \"
|
|
1
|
+
{"version":3,"file":"resource.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/resource.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { resourceStub } from \"../templates/stubs\";\r\nimport { putFileAsync, setDryRun } from \"../utils/writer\";\r\nimport { parseModulePath, parseName } from \"../utils/name-parser\";\r\nimport {\r\n componentExists,\r\n ensureComponentDirectory,\r\n moduleExists,\r\n resolveComponentPath,\r\n} from \"../utils/path-resolver\";\r\n\r\nexport async function generateResource(data: CommandActionData): Promise<void> {\r\n const input = data.args[0];\r\n\r\n if (!input) {\r\n console.log(colors.red(\"Error: Resource name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.resource <module>/<name>\"));\r\n console.log(colors.yellow(\"Example: warlock create.resource users/user\"));\r\n process.exit(1);\r\n }\r\n\r\n const { module, name: componentName } = parseModulePath(input);\r\n\r\n if (!module) {\r\n console.log(colors.red(\"Error: Module name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.resource <module>/<name>\"));\r\n process.exit(1);\r\n }\r\n\r\n // Check if module exists\r\n if (!(await moduleExists(module))) {\r\n console.log(colors.red(`Error: Module \"${module}\" does not exist`));\r\n console.log(colors.yellow(`Run: warlock create.module ${module}`));\r\n process.exit(1);\r\n }\r\n\r\n const name = parseName(componentName);\r\n const force = data.options.force || data.options.f;\r\n setDryRun(Boolean(data.options.dryRun));\r\n\r\n // Check if resource already exists\r\n if ((await componentExists(module, \"resources\", `${name.kebab}.resource`)) && !force) {\r\n console.log(colors.red(`Error: Resource \"${name.kebab}.resource.ts\" already exists`));\r\n console.log(colors.yellow(\"Use --force to overwrite\"));\r\n process.exit(1);\r\n }\r\n\r\n // Ensure directories exist\r\n await ensureComponentDirectory(module, \"resources\");\r\n\r\n // Generate resource\r\n const resourcePath = resolveComponentPath(module, \"resources\", `${name.kebab}.resource`);\r\n const resourceContent = resourceStub(name);\r\n\r\n await putFileAs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D,QAAQ,IAAI,OAAO,KAAK,mBAAmB,KAAK,OAAO,kCAAkC,CAAC;AAC5F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/service.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport type { CommandActionData } from \"
|
|
1
|
+
{"version":3,"file":"service.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/service.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { serviceStub } from \"../templates/stubs\";\r\nimport { putFileAsync, setDryRun } from \"../utils/writer\";\r\nimport { parseModulePath, parseName } from \"../utils/name-parser\";\r\nimport {\r\n componentExists,\r\n ensureComponentDirectory,\r\n moduleExists,\r\n resolveComponentPath,\r\n} from \"../utils/path-resolver\";\r\n\r\nexport async function generateService(data: CommandActionData): Promise<void> {\r\n const input = data.args[0];\r\n\r\n if (!input) {\r\n console.log(colors.red(\"Error: Service name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.service <module>/<name>\"));\r\n console.log(colors.yellow(\"Example: warlock create.service users/create-user\"));\r\n process.exit(1);\r\n }\r\n\r\n const { module, name: componentName } = parseModulePath(input);\r\n\r\n if (!module) {\r\n console.log(colors.red(\"Error: Module name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.service <module>/<name>\"));\r\n process.exit(1);\r\n }\r\n\r\n // Check if module exists\r\n if (!(await moduleExists(module))) {\r\n console.log(colors.red(`Error: Module \"${module}\" does not exist`));\r\n console.log(colors.yellow(`Run: warlock create.module ${module}`));\r\n process.exit(1);\r\n }\r\n\r\n const name = parseName(componentName);\r\n const force = data.options.force || data.options.f;\r\n setDryRun(Boolean(data.options.dryRun));\r\n\r\n // Check if service already exists\r\n if ((await componentExists(module, \"services\", `${name.kebab}.service`)) && !force) {\r\n console.log(colors.red(`Error: Service \"${name.kebab}.service.ts\" already exists`));\r\n console.log(colors.yellow(\"Use --force to overwrite\"));\r\n process.exit(1);\r\n }\r\n\r\n // Ensure directories exist\r\n await ensureComponentDirectory(module, \"services\");\r\n\r\n // Generate service\r\n const servicePath = resolveComponentPath(module, \"services\", `${name.kebab}.service`);\r\n const serviceContent = serviceStub(name);\r\n\r\n await putFileAsync(servicePath, serviceContent);\r\n\r\n console.log(colors.cyan(`\\n✨ Service \"${name.camel}\" generated successfully!`));\r\n}\r\n"],"mappings":";;;;;;;AAYA,eAAsB,gBAAgB,MAAwC;CAC5E,MAAM,QAAQ,KAAK,KAAK;CAExB,IAAI,CAAC,OAAO;EACV,QAAQ,IAAI,OAAO,IAAI,iCAAiC,CAAC;EACzD,QAAQ,IAAI,OAAO,OAAO,+CAA+C,CAAC;EAC1E,QAAQ,IAAI,OAAO,OAAO,mDAAmD,CAAC;EAC9E,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,EAAE,QAAQ,MAAM,kBAAkB,gBAAgB,KAAK;CAE7D,IAAI,CAAC,QAAQ;EACX,QAAQ,IAAI,OAAO,IAAI,gCAAgC,CAAC;EACxD,QAAQ,IAAI,OAAO,OAAO,+CAA+C,CAAC;EAC1E,QAAQ,KAAK,CAAC;CAChB;CAGA,IAAI,CAAE,MAAM,aAAa,MAAM,GAAI;EACjC,QAAQ,IAAI,OAAO,IAAI,kBAAkB,OAAO,iBAAiB,CAAC;EAClE,QAAQ,IAAI,OAAO,OAAO,8BAA8B,QAAQ,CAAC;EACjE,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,OAAO,UAAU,aAAa;CACpC,MAAM,QAAQ,KAAK,QAAQ,SAAS,KAAK,QAAQ;CACjD,UAAU,QAAQ,KAAK,QAAQ,MAAM,CAAC;CAGtC,IAAK,MAAM,gBAAgB,QAAQ,YAAY,GAAG,KAAK,MAAM,SAAS,KAAM,CAAC,OAAO;EAClF,QAAQ,IAAI,OAAO,IAAI,mBAAmB,KAAK,MAAM,4BAA4B,CAAC;EAClF,QAAQ,IAAI,OAAO,OAAO,0BAA0B,CAAC;EACrD,QAAQ,KAAK,CAAC;CAChB;CAGA,MAAM,yBAAyB,QAAQ,UAAU;CAMjD,MAAM,aAHc,qBAAqB,QAAQ,YAAY,GAAG,KAAK,MAAM,SAG9C,GAFN,YAAY,IAEU,CAAC;CAE9C,QAAQ,IAAI,OAAO,KAAK,kBAAkB,KAAK,MAAM,0BAA0B,CAAC;AAClF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { appPath } from "../../../../utils/paths.mjs";
|
|
2
2
|
import "../../../../utils/index.mjs";
|
|
3
3
|
import { ensureDirectoryAsync as ensureDirectoryAsync$1 } from "./writer.mjs";
|
|
4
|
-
import { directoryExistsAsync, fileExistsAsync } from "@warlock.js/fs";
|
|
5
4
|
import path from "node:path";
|
|
5
|
+
import { directoryExistsAsync, fileExistsAsync } from "@warlock.js/fs";
|
|
6
6
|
|
|
7
7
|
//#region ../core/src/cli/commands/generate/utils/path-resolver.ts
|
|
8
8
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { command } from "
|
|
1
|
+
import { command } from "../../commands/cli-command.mjs";
|
|
2
2
|
import { migrateAction } from "../../database/migrate-action.mjs";
|
|
3
3
|
|
|
4
4
|
//#region ../core/src/cli/commands/migrate.command.ts
|
|
@@ -8,7 +8,6 @@ const migrateCommand = command({
|
|
|
8
8
|
description: "Run database migrations",
|
|
9
9
|
preload: {
|
|
10
10
|
config: ["database", "log"],
|
|
11
|
-
env: true,
|
|
12
11
|
connectors: ["database", "logger"]
|
|
13
12
|
},
|
|
14
13
|
options: [
|
|
@@ -29,7 +28,12 @@ const migrateCommand = command({
|
|
|
29
28
|
},
|
|
30
29
|
{
|
|
31
30
|
text: "--list, -l",
|
|
32
|
-
description: "
|
|
31
|
+
description: "Show migration state: executed migrations, then what will run next",
|
|
32
|
+
type: "boolean"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
text: "--pending",
|
|
36
|
+
description: "List only what will run next, in execution order. Exits 0 if nothing is pending, 1 if something is, 2 if it could not be determined",
|
|
33
37
|
type: "boolean"
|
|
34
38
|
},
|
|
35
39
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/migrate.command.ts"],"sourcesContent":["import { migrateAction } from \"../../database/migrate-action\";\nimport { command } from \"
|
|
1
|
+
{"version":3,"file":"migrate.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/migrate.command.ts"],"sourcesContent":["import { migrateAction } from \"../../database/migrate-action\";\r\nimport { command } from \"../../commands/cli-command\";\r\n\r\nexport const migrateCommand = command({\r\n action: migrateAction,\r\n name: \"migrate\",\r\n description: \"Run database migrations\",\r\n preload: {\r\n config: [\"database\", \"log\"],\r\n connectors: [\"database\", \"logger\"],\r\n },\r\n options: [\r\n {\r\n text: \"--fresh, -f\",\r\n description: \"Drop all tables and re-run migrations\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--rollback, -r\",\r\n description: \"Rollback migrations, drop all tables\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--path, -p\",\r\n description: \"Migration file path, if not provided, all migrations will be wroking\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--list, -l\",\r\n description: \"Show migration state: executed migrations, then what will run next\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--pending\",\r\n description:\r\n \"List only what will run next, in execution order. Exits 0 if nothing is pending, 1 if something is, 2 if it could not be determined\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--all, -a\",\r\n description: \"List all migrations files in the app\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--sql, -s\",\r\n description: \"Export all migrations as phase-ordered SQL files instead of executing them\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--pending-only\",\r\n description: \"When used with --sql, exports only pending migrations instead of all\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--compact, -c\",\r\n description:\r\n \"When used with --sql, strips out generated comments and blank lines to reduce file size\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n"],"mappings":";;;;AAGA,MAAa,iBAAiB,QAAQ;CACpC,QAAQ;CACR,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ,CAAC,YAAY,KAAK;EAC1B,YAAY,CAAC,YAAY,QAAQ;CACnC;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-command.action.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/routes-command.action.ts"],"sourcesContent":["import { router } from \"../../../router/router\";\nimport type { CommandActionData } from \"
|
|
1
|
+
{"version":3,"file":"routes-command.action.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/routes-command.action.ts"],"sourcesContent":["import { router } from \"../../../router/router\";\r\nimport type { CommandActionData } from \"../../../commands/types\";\r\nimport { printRoutesTable } from \"./format-routes-table\";\r\nimport { filterRouteRows, sortRouteRows, toRouteRow } from \"./route-row\";\r\n\r\n/**\r\n * Read the active option as a trimmed string, or `undefined` when it is absent\r\n * or not a string (a bare boolean flag).\r\n *\r\n * @param value - The parsed option value\r\n * @returns The string value, or `undefined`\r\n */\r\nfunction stringOption(value: string | number | boolean | undefined): string | undefined {\r\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\r\n}\r\n\r\n/**\r\n * Action behind `warlock routes`. Reads the registered routes from the router\r\n * singleton (populated by the `bootstrap` preload, with no connectors started),\r\n * applies the `--method` / `--path` / `--name` filters, sorts them, and either\r\n * prints a verb-colored table or — with `--json` — emits the normalized rows as\r\n * JSON for piping into scripts/CI.\r\n *\r\n * Read-only: it never opens a database/cache/socket connection and never\r\n * mutates the router.\r\n *\r\n * @param data - Parsed CLI args (`options.method` / `path` / `name` / `json`).\r\n */\r\nexport function routesCommandAction({ options }: CommandActionData): void {\r\n const rows = sortRouteRows(\r\n filterRouteRows(router.list().map(toRouteRow), {\r\n method: stringOption(options.method),\r\n path: stringOption(options.path),\r\n name: stringOption(options.name),\r\n }),\r\n );\r\n\r\n if (options.json) {\r\n console.log(JSON.stringify(rows, null, 2));\r\n return;\r\n }\r\n\r\n printRoutesTable(rows);\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAYA,SAAS,aAAa,OAAkE;CACtF,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,SAAS,IAAI,MAAM,KAAK,IAAI;AAC/E;;;;;;;;;;;;;AAcA,SAAgB,oBAAoB,EAAE,WAAoC;CACxE,MAAM,OAAO,cACX,gBAAgB,OAAO,KAAK,CAAC,CAAC,IAAI,UAAU,GAAG;EAC7C,QAAQ,aAAa,QAAQ,MAAM;EACnC,MAAM,aAAa,QAAQ,IAAI;EAC/B,MAAM,aAAa,QAAQ,IAAI;CACjC,CAAC,CACH;CAEA,IAAI,QAAQ,MAAM;EAChB,QAAQ,IAAI,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;EACzC;CACF;CAEA,iBAAiB,IAAI;AACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/routes.command.ts"],"sourcesContent":["import { command } from \"
|
|
1
|
+
{"version":3,"file":"routes.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/routes.command.ts"],"sourcesContent":["import { command } from \"../../commands/cli-command\";\r\nimport { routesCommandAction } from \"./routes/routes-command.action\";\r\n\r\n/**\r\n * `warlock routes` — list every registered HTTP route as a table (a read-only\r\n * sibling of `warlock doctor`). Filter with `--method` / `--path` / `--name`,\r\n * or emit the normalized rows as JSON with `--json`.\r\n *\r\n * Preload plan: load config + bootstrap app code so route modules register on\r\n * the router singleton, but start NO connectors — listing routes must never\r\n * open a database/cache/socket connection. Because the route-module loader is\r\n * fail-loud, a route file that throws on import surfaces here instead of being\r\n * silently omitted from the table.\r\n */\r\nexport const routesCommand = command({\r\n name: \"routes\",\r\n description:\r\n \"List the registered HTTP routes as a table (read-only); filter with --method / --path / --name, or emit JSON with --json\",\r\n action: routesCommandAction,\r\n preload: {\r\n config: true,\r\n env: true,\r\n bootstrap: true,\r\n },\r\n options: [\r\n {\r\n text: \"--method, -m\",\r\n description: \"Filter by HTTP method (case-insensitive, e.g. GET, POST)\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--path, -p\",\r\n description: \"Filter by a case-insensitive path substring\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--name, -n\",\r\n description: \"Filter by a case-insensitive route-name substring\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--json, -j\",\r\n description: \"Output the routes as JSON instead of a table\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,gBAAgB,QAAQ;CACnC,MAAM;CACN,aACE;CACF,QAAQ;CACR,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;CACb;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/seed.command.ts"],"sourcesContent":["import { seedCommandAction } from \"../../database/seed-command-action\";\nimport { command } from \"
|
|
1
|
+
{"version":3,"file":"seed.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/seed.command.ts"],"sourcesContent":["import { seedCommandAction } from \"../../database/seed-command-action\";\r\nimport { command } from \"../../commands/cli-command\";\r\n\r\nexport const seedCommand = command({\r\n action: seedCommandAction,\r\n name: \"seed\",\r\n description: \"Run database seeds\",\r\n preload: {\r\n config: true,\r\n env: true,\r\n bootstrap: true,\r\n connectors: [\"database\", \"cache\", \"logger\"],\r\n },\r\n options: [\r\n {\r\n text: \"--fresh, -f\",\r\n description: \"Drop all tables records and run seeds\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--list, -l\",\r\n description: \"Display the seeds list in order without execution\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--transaction, -t\",\r\n description: \"Run seeds in a transaction\",\r\n type: \"boolean\",\r\n defaultValue: true,\r\n },\r\n {\r\n text: \"--drop, -d\",\r\n description:\r\n 'Undo seeded data — delete tracked records (reverse order) and reset the seed log; scope to one seeder with --drop=\"Seed Name\"',\r\n type: \"string\",\r\n },\r\n ],\r\n});\r\n"],"mappings":";;;;AAGA,MAAa,cAAc,QAAQ;CACjC,QAAQ;CACR,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;EACX,YAAY;GAAC;GAAY;GAAS;EAAQ;CAC5C;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACN,cAAc;EAChB;EACA;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;CACF;AACF,CAAC"}
|