@bogomolcompany/bogo 0.1.2 → 0.2.2
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/README.md +62 -12
- package/README.ru.md +62 -19
- package/dist/cli.js +92 -20
- package/dist/cli.js.map +1 -1
- package/dist/commands/add-method.d.ts.map +1 -1
- package/dist/commands/add-method.js +10 -11
- package/dist/commands/add-method.js.map +1 -1
- package/dist/commands/create-app.d.ts +2 -1
- package/dist/commands/create-app.d.ts.map +1 -1
- package/dist/commands/create-app.js +2 -2
- package/dist/commands/create-app.js.map +1 -1
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +53 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/generate-module.d.ts.map +1 -1
- package/dist/commands/generate-module.js +21 -16
- package/dist/commands/generate-module.js.map +1 -1
- package/dist/commands/interactive.d.ts +3 -0
- package/dist/commands/interactive.d.ts.map +1 -0
- package/dist/commands/interactive.js +65 -0
- package/dist/commands/interactive.js.map +1 -0
- package/dist/commands/list-modules.d.ts +2 -0
- package/dist/commands/list-modules.d.ts.map +1 -0
- package/dist/commands/list-modules.js +36 -0
- package/dist/commands/list-modules.js.map +1 -0
- package/dist/commands/remove-module.d.ts +2 -1
- package/dist/commands/remove-module.d.ts.map +1 -1
- package/dist/commands/remove-module.js +61 -10
- package/dist/commands/remove-module.js.map +1 -1
- package/dist/templates/module.d.ts +14 -7
- package/dist/templates/module.d.ts.map +1 -1
- package/dist/templates/module.js +38 -63
- package/dist/templates/module.js.map +1 -1
- package/dist/templates/project.d.ts +2 -1
- package/dist/templates/project.d.ts.map +1 -1
- package/dist/templates/project.js +85 -17
- package/dist/templates/project.js.map +1 -1
- package/dist/templates/render-helpers.d.ts +9 -0
- package/dist/templates/render-helpers.d.ts.map +1 -0
- package/dist/templates/render-helpers.js +78 -0
- package/dist/templates/render-helpers.js.map +1 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +6 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/http.d.ts +5 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/http.js +13 -0
- package/dist/utils/http.js.map +1 -0
- package/dist/utils/index-path.d.ts +7 -0
- package/dist/utils/index-path.d.ts.map +1 -0
- package/dist/utils/index-path.js +25 -0
- package/dist/utils/index-path.js.map +1 -0
- package/dist/utils/io.d.ts +8 -0
- package/dist/utils/io.d.ts.map +1 -0
- package/dist/utils/io.js +31 -0
- package/dist/utils/io.js.map +1 -0
- package/dist/utils/method-spec.d.ts +4 -0
- package/dist/utils/method-spec.d.ts.map +1 -0
- package/dist/utils/method-spec.js +49 -0
- package/dist/utils/method-spec.js.map +1 -0
- package/dist/utils/patch-index.d.ts +8 -4
- package/dist/utils/patch-index.d.ts.map +1 -1
- package/dist/utils/patch-index.js +33 -28
- package/dist/utils/patch-index.js.map +1 -1
- package/dist/utils/patch-method.d.ts +13 -20
- package/dist/utils/patch-method.d.ts.map +1 -1
- package/dist/utils/patch-method.js +66 -37
- package/dist/utils/patch-method.js.map +1 -1
- package/dist/utils/template-loader.d.ts +3 -0
- package/dist/utils/template-loader.d.ts.map +1 -0
- package/dist/utils/template-loader.js +17 -0
- package/dist/utils/template-loader.js.map +1 -0
- package/docs/demo/bogo-demo.gif +0 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
[Русская версия / Russian version](README.ru.md)
|
|
8
8
|
|
|
9
|
-
**`bogo create app`** — Express + TypeScript project in 10 seconds.
|
|
10
|
-
**`bogo g users`** — controller, service, dto, routes, validator in one command.
|
|
9
|
+
**`bogo create app`** — Express + TypeScript project in 10 seconds.
|
|
10
|
+
**`bogo g users`** — controller, service, dto, routes, validator in one command.
|
|
11
11
|
**`bogo r users`** — remove a module and clean up the index file.
|
|
12
12
|
|
|
13
13
|
CLI generator for Express API. Works in any repository — configured via `.bogorc.json`.
|
|
14
14
|
|
|
15
|
+

|
|
16
|
+
|
|
15
17
|
## Quick start
|
|
16
18
|
|
|
17
19
|
```bash
|
|
@@ -58,8 +60,7 @@ npm link
|
|
|
58
60
|
## Create a new project
|
|
59
61
|
|
|
60
62
|
```bash
|
|
61
|
-
|
|
62
|
-
bogo create app
|
|
63
|
+
bogo create app my-api --with-docker --with-eslint
|
|
63
64
|
```
|
|
64
65
|
|
|
65
66
|
Or into a subdirectory:
|
|
@@ -109,15 +110,19 @@ Creates `.bogorc.json`:
|
|
|
109
110
|
{
|
|
110
111
|
"apiDir": "src/api",
|
|
111
112
|
"indexFile": "src/index.ts",
|
|
112
|
-
"routePrefix": "/api"
|
|
113
|
+
"routePrefix": "/api",
|
|
114
|
+
"templatesDir": "./bogo-templates"
|
|
113
115
|
}
|
|
114
116
|
```
|
|
115
117
|
|
|
118
|
+
`templatesDir` is optional. Place `controller.template`, `service.template`, etc. to override built-in templates.
|
|
119
|
+
|
|
116
120
|
## Generate a module
|
|
117
121
|
|
|
118
122
|
```bash
|
|
119
123
|
bogo g analytics -m getStats -m getReport
|
|
120
|
-
bogo g orders -m createOrder:/create -m getOrder:/:id
|
|
124
|
+
bogo g orders -m createOrder:POST:/create -m getOrder:GET:/:id
|
|
125
|
+
bogo g posts -m getList:GET:/list -w auth
|
|
121
126
|
```
|
|
122
127
|
|
|
123
128
|
Creates:
|
|
@@ -170,6 +175,33 @@ bogo g method users -m getList -p controller -p service -p dto
|
|
|
170
175
|
|
|
171
176
|
`-m` is required. `-p` is optional — without it, all found files are updated.
|
|
172
177
|
|
|
178
|
+
## Remove a method
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
bogo r method users -m getList
|
|
182
|
+
bogo r method users -m createUser -p controller -p service
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## List modules
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
bogo list
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Doctor
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
bogo doctor
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Checks `.bogorc.json`, index file, api directory, and required middleware.
|
|
198
|
+
|
|
199
|
+
## Interactive mode
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
bogo g --interactive
|
|
203
|
+
```
|
|
204
|
+
|
|
173
205
|
## Remove a module
|
|
174
206
|
|
|
175
207
|
```bash
|
|
@@ -179,13 +211,28 @@ bogo r orders --skip-index
|
|
|
179
211
|
|
|
180
212
|
Removes the module folder and cleans up import + `app.use` in the index file.
|
|
181
213
|
|
|
214
|
+
## Method spec format
|
|
215
|
+
|
|
216
|
+
| Example | Result |
|
|
217
|
+
|---------|--------|
|
|
218
|
+
| `getList` | POST `/get-list` |
|
|
219
|
+
| `getList:GET` | GET `/get-list` |
|
|
220
|
+
| `getOrder:GET:/:id` | GET `/:id` |
|
|
221
|
+
| `createOrder:POST:/create` | POST `/create` |
|
|
222
|
+
|
|
182
223
|
## Options
|
|
183
224
|
|
|
184
225
|
| Flag | Description |
|
|
185
226
|
|------|-------------|
|
|
186
|
-
| `-m, --method` | Method
|
|
187
|
-
| `-p, --part` | Target a specific part
|
|
188
|
-
|
|
|
227
|
+
| `-m, --method` | Method spec (repeatable). See table above |
|
|
228
|
+
| `-p, --part` | Target a specific part |
|
|
229
|
+
| `-w, --middleware` | Route middleware name (repeatable) |
|
|
230
|
+
| `-i, --interactive` | Interactive generate |
|
|
231
|
+
| `--dry-run` | Preview changes without writing |
|
|
232
|
+
| `--force` | Overwrite existing files |
|
|
233
|
+
| `--skip-index` | Do not patch the index file |
|
|
234
|
+
| `--with-docker` | Add Docker files to `create app` |
|
|
235
|
+
| `--with-eslint` | Add ESLint to `create app` |
|
|
189
236
|
|
|
190
237
|
## Target project requirements
|
|
191
238
|
|
|
@@ -200,10 +247,13 @@ Removes the module folder and cleans up import + `app.use` in the index file.
|
|
|
200
247
|
|
|
201
248
|
```bash
|
|
202
249
|
npm run build
|
|
203
|
-
npm
|
|
204
|
-
npm run dev --
|
|
250
|
+
npm test
|
|
251
|
+
npm run dev -- create app ./tmp-app --with-eslint
|
|
252
|
+
npm run dev -- g test -m getList:GET
|
|
205
253
|
npm run dev -- g method test -m createUser
|
|
206
|
-
npm run dev -- r test
|
|
254
|
+
npm run dev -- r method test -m createUser
|
|
255
|
+
npm run dev -- list
|
|
256
|
+
npm run dev -- doctor
|
|
207
257
|
```
|
|
208
258
|
|
|
209
259
|
## Links
|
package/README.ru.md
CHANGED
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
[English version](README.md)
|
|
8
8
|
|
|
9
|
-
**`bogo create app`** — Express + TypeScript проект за 10 секунд.
|
|
10
|
-
**`bogo g users`** — controller, service, dto, routes, validator одной командой.
|
|
9
|
+
**`bogo create app`** — Express + TypeScript проект за 10 секунд.
|
|
10
|
+
**`bogo g users`** — controller, service, dto, routes, validator одной командой.
|
|
11
11
|
**`bogo r users`** — удаляет модуль и убирает роут из index.
|
|
12
12
|
|
|
13
13
|
CLI-генератор для Express API. Не привязан к конкретному репозиторию — настраивается через `.bogorc.json`.
|
|
14
14
|
|
|
15
|
+

|
|
16
|
+
|
|
15
17
|
## Быстрый старт
|
|
16
18
|
|
|
17
19
|
```bash
|
|
@@ -58,15 +60,7 @@ npm link
|
|
|
58
60
|
## Создание нового проекта
|
|
59
61
|
|
|
60
62
|
```bash
|
|
61
|
-
|
|
62
|
-
bogo create app
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Или в подпапку:
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
bogo create app my-api
|
|
69
|
-
cd my-api
|
|
63
|
+
bogo create app my-api --with-docker --with-eslint
|
|
70
64
|
```
|
|
71
65
|
|
|
72
66
|
Создаёт:
|
|
@@ -109,15 +103,19 @@ bogo init
|
|
|
109
103
|
{
|
|
110
104
|
"apiDir": "src/api",
|
|
111
105
|
"indexFile": "src/index.ts",
|
|
112
|
-
"routePrefix": "/api"
|
|
106
|
+
"routePrefix": "/api",
|
|
107
|
+
"templatesDir": "./bogo-templates"
|
|
113
108
|
}
|
|
114
109
|
```
|
|
115
110
|
|
|
111
|
+
`templatesDir` — опционально. Файлы `controller.template`, `service.template` и т.д. переопределяют встроенные шаблоны.
|
|
112
|
+
|
|
116
113
|
## Генерация модуля
|
|
117
114
|
|
|
118
115
|
```bash
|
|
119
116
|
bogo g analytics -m getStats -m getReport
|
|
120
|
-
bogo g orders -m createOrder:/create -m getOrder:/:id
|
|
117
|
+
bogo g orders -m createOrder:POST:/create -m getOrder:GET:/:id
|
|
118
|
+
bogo g posts -m getList:GET:/list -w auth
|
|
121
119
|
```
|
|
122
120
|
|
|
123
121
|
Создаёт:
|
|
@@ -170,6 +168,33 @@ bogo g method users -m getList -p controller -p service -p dto
|
|
|
170
168
|
|
|
171
169
|
`-m` обязателен. `-p` — опционально, без него обновляются все найденные файлы.
|
|
172
170
|
|
|
171
|
+
## Удаление метода
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
bogo r method users -m getList
|
|
175
|
+
bogo r method users -m createUser -p controller -p service
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Список модулей
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
bogo list
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Doctor
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
bogo doctor
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Проверяет `.bogorc.json`, index, api-папку и middleware.
|
|
191
|
+
|
|
192
|
+
## Интерактивный режим
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
bogo g --interactive
|
|
196
|
+
```
|
|
197
|
+
|
|
173
198
|
## Удаление модуля
|
|
174
199
|
|
|
175
200
|
```bash
|
|
@@ -179,13 +204,28 @@ bogo r orders --skip-index
|
|
|
179
204
|
|
|
180
205
|
Удаляет папку модуля и убирает import + `app.use` из index.
|
|
181
206
|
|
|
207
|
+
## Формат `-m`
|
|
208
|
+
|
|
209
|
+
| Пример | Результат |
|
|
210
|
+
|--------|-----------|
|
|
211
|
+
| `getList` | POST `/get-list` |
|
|
212
|
+
| `getList:GET` | GET `/get-list` |
|
|
213
|
+
| `getOrder:GET:/:id` | GET `/:id` |
|
|
214
|
+
| `createOrder:POST:/create` | POST `/create` |
|
|
215
|
+
|
|
182
216
|
## Опции
|
|
183
217
|
|
|
184
218
|
| Флаг | Описание |
|
|
185
219
|
|------|----------|
|
|
186
|
-
| `-m, --method` |
|
|
187
|
-
| `-p, --part` | Только указанная часть
|
|
188
|
-
|
|
|
220
|
+
| `-m, --method` | Спецификация метода (повторяемый) |
|
|
221
|
+
| `-p, --part` | Только указанная часть |
|
|
222
|
+
| `-w, --middleware` | Middleware для роута (повторяемый) |
|
|
223
|
+
| `-i, --interactive` | Интерактивная генерация |
|
|
224
|
+
| `--dry-run` | Показать изменения без записи |
|
|
225
|
+
| `--force` | Перезаписать существующие файлы |
|
|
226
|
+
| `--skip-index` | Не править index-файл |
|
|
227
|
+
| `--with-docker` | Docker-файлы в `create app` |
|
|
228
|
+
| `--with-eslint` | ESLint в `create app` |
|
|
189
229
|
|
|
190
230
|
## Требования к целевому проекту
|
|
191
231
|
|
|
@@ -200,10 +240,13 @@ bogo r orders --skip-index
|
|
|
200
240
|
|
|
201
241
|
```bash
|
|
202
242
|
npm run build
|
|
203
|
-
npm
|
|
204
|
-
npm run dev --
|
|
243
|
+
npm test
|
|
244
|
+
npm run dev -- create app ./tmp-app --with-eslint
|
|
245
|
+
npm run dev -- g test -m getList:GET
|
|
205
246
|
npm run dev -- g method test -m createUser
|
|
206
|
-
npm run dev -- r test
|
|
247
|
+
npm run dev -- r method test -m createUser
|
|
248
|
+
npm run dev -- list
|
|
249
|
+
npm run dev -- doctor
|
|
207
250
|
```
|
|
208
251
|
|
|
209
252
|
## Ссылки
|
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
4
6
|
const commander_1 = require("commander");
|
|
5
7
|
const add_method_1 = require("./commands/add-method");
|
|
6
8
|
const create_app_1 = require("./commands/create-app");
|
|
9
|
+
const doctor_1 = require("./commands/doctor");
|
|
7
10
|
const generate_module_1 = require("./commands/generate-module");
|
|
11
|
+
const interactive_1 = require("./commands/interactive");
|
|
12
|
+
const list_modules_1 = require("./commands/list-modules");
|
|
8
13
|
const remove_module_1 = require("./commands/remove-module");
|
|
9
14
|
const parts_1 = require("./utils/parts");
|
|
15
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, "../package.json"), "utf-8"));
|
|
10
16
|
const program = new commander_1.Command();
|
|
11
|
-
program.name("bogo").description("CLI generator for Express API modules").version(
|
|
17
|
+
program.name("bogo").description("CLI generator for Express API modules").version(pkg.version);
|
|
12
18
|
program
|
|
13
19
|
.command("init")
|
|
14
20
|
.description("Create .bogorc.json in the current directory")
|
|
@@ -26,12 +32,16 @@ program
|
|
|
26
32
|
.description("Create a new project")
|
|
27
33
|
.argument("<type>", "project type (app)")
|
|
28
34
|
.argument("[path]", "target directory", ".")
|
|
29
|
-
.
|
|
35
|
+
.option("--with-docker", "Add Dockerfile and docker-compose.yml", false)
|
|
36
|
+
.option("--with-eslint", "Add ESLint config", false)
|
|
37
|
+
.option("--dry-run", "Preview files without writing", false)
|
|
38
|
+
.option("--force", "Overwrite existing files", false)
|
|
39
|
+
.action((type, path, options) => {
|
|
30
40
|
try {
|
|
31
41
|
if (type !== "app") {
|
|
32
42
|
throw new Error(`Unknown type "${type}". Available: app`);
|
|
33
43
|
}
|
|
34
|
-
(0, create_app_1.runCreateApp)(process.cwd(), path);
|
|
44
|
+
(0, create_app_1.runCreateApp)(process.cwd(), path, options);
|
|
35
45
|
}
|
|
36
46
|
catch (error) {
|
|
37
47
|
console.error(error instanceof Error ? error.message : error);
|
|
@@ -39,20 +49,52 @@ program
|
|
|
39
49
|
}
|
|
40
50
|
});
|
|
41
51
|
program
|
|
52
|
+
.command("list")
|
|
53
|
+
.description("List API modules in the project")
|
|
54
|
+
.action(() => {
|
|
55
|
+
try {
|
|
56
|
+
(0, list_modules_1.runList)(process.cwd());
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error(error instanceof Error ? error.message : error);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
program
|
|
64
|
+
.command("doctor")
|
|
65
|
+
.description("Check project setup for bogo")
|
|
66
|
+
.action(() => {
|
|
67
|
+
try {
|
|
68
|
+
(0, doctor_1.runDoctor)(process.cwd());
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error(error instanceof Error ? error.message : error);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const generate = program
|
|
42
76
|
.command("generate")
|
|
43
77
|
.alias("g")
|
|
44
78
|
.description("Generate API module, part, or method")
|
|
45
|
-
.argument("
|
|
79
|
+
.argument("[target]", "module name, part, or method")
|
|
46
80
|
.argument("[name]", "module name for part/method")
|
|
47
|
-
.option("-m, --method <method>", "method
|
|
48
|
-
.option("-p, --part <part>", "target part only (repeatable)
|
|
49
|
-
.option("--
|
|
50
|
-
.
|
|
81
|
+
.option("-m, --method <method>", "method spec (repeatable): getList, getList:GET, getOrder:GET:/:id", collect, [])
|
|
82
|
+
.option("-p, --part <part>", "target part only (repeatable)", collect, [])
|
|
83
|
+
.option("-w, --middleware <name>", "route middleware (repeatable)", collect, [])
|
|
84
|
+
.option("-i, --interactive", "Interactive mode", false)
|
|
85
|
+
.option("--skip-index", "Do not patch index file", false)
|
|
86
|
+
.option("--dry-run", "Preview changes without writing", false)
|
|
87
|
+
.option("--force", "Overwrite existing files", false)
|
|
88
|
+
.action(async (target, name, options) => {
|
|
51
89
|
try {
|
|
52
|
-
const generateOptions =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
90
|
+
const generateOptions = buildGenerateOptions(options);
|
|
91
|
+
if (options.interactive) {
|
|
92
|
+
await (0, interactive_1.runInteractiveGenerate)(process.cwd(), generateOptions);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!target) {
|
|
96
|
+
throw new Error("Target required. Example: bogo g users -m getList");
|
|
97
|
+
}
|
|
56
98
|
if (target === "method") {
|
|
57
99
|
if (!name) {
|
|
58
100
|
throw new Error("Module name required. Example: bogo g method users -m getList");
|
|
@@ -60,8 +102,12 @@ program
|
|
|
60
102
|
if (options.method.length === 0) {
|
|
61
103
|
throw new Error("At least one -m is required. Example: bogo g method users -m getList");
|
|
62
104
|
}
|
|
63
|
-
|
|
64
|
-
|
|
105
|
+
(0, add_method_1.runAddMethod)(process.cwd(), name, {
|
|
106
|
+
methods: options.method,
|
|
107
|
+
parts: parseParts(options.part),
|
|
108
|
+
dryRun: options.dryRun,
|
|
109
|
+
middleware: options.middleware,
|
|
110
|
+
});
|
|
65
111
|
return;
|
|
66
112
|
}
|
|
67
113
|
if ((0, parts_1.isModulePart)(target)) {
|
|
@@ -84,13 +130,30 @@ program
|
|
|
84
130
|
program
|
|
85
131
|
.command("remove")
|
|
86
132
|
.alias("r")
|
|
87
|
-
.description("Remove API module or
|
|
88
|
-
.argument("<target>", "module name or
|
|
89
|
-
.argument("[name]", "module name
|
|
90
|
-
.option("--
|
|
133
|
+
.description("Remove API module, part, or method")
|
|
134
|
+
.argument("<target>", "module name, part, or method")
|
|
135
|
+
.argument("[name]", "module name for part/method")
|
|
136
|
+
.option("-m, --method <method>", "method name to remove (repeatable)", collect, [])
|
|
137
|
+
.option("-p, --part <part>", "target part only (repeatable)", collect, [])
|
|
138
|
+
.option("--skip-index", "Do not patch index file", false)
|
|
139
|
+
.option("--dry-run", "Preview changes without writing", false)
|
|
91
140
|
.action((target, name, options) => {
|
|
92
141
|
try {
|
|
93
|
-
const removeOptions = { skipIndex: options.skipIndex };
|
|
142
|
+
const removeOptions = { skipIndex: options.skipIndex, dryRun: options.dryRun };
|
|
143
|
+
if (target === "method") {
|
|
144
|
+
if (!name) {
|
|
145
|
+
throw new Error("Module name required. Example: bogo r method users -m getList");
|
|
146
|
+
}
|
|
147
|
+
if (options.method.length === 0) {
|
|
148
|
+
throw new Error("At least one -m is required. Example: bogo r method users -m getList");
|
|
149
|
+
}
|
|
150
|
+
(0, remove_module_1.runRemoveMethod)(process.cwd(), name, {
|
|
151
|
+
methods: options.method,
|
|
152
|
+
parts: parseParts(options.part),
|
|
153
|
+
dryRun: options.dryRun,
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
94
157
|
if ((0, parts_1.isModulePart)(target)) {
|
|
95
158
|
if (!name) {
|
|
96
159
|
throw new Error(`Module name required. Example: bogo r ${target} users`);
|
|
@@ -99,7 +162,7 @@ program
|
|
|
99
162
|
return;
|
|
100
163
|
}
|
|
101
164
|
if (name) {
|
|
102
|
-
throw new Error(`Unexpected argument "${name}". Use: bogo r <module> or bogo r <
|
|
165
|
+
throw new Error(`Unexpected argument "${name}". Use: bogo r <module>, bogo r <part> <module>, or bogo r method <module> -m <name>`);
|
|
103
166
|
}
|
|
104
167
|
(0, remove_module_1.runRemoveModule)(process.cwd(), target, removeOptions);
|
|
105
168
|
}
|
|
@@ -121,5 +184,14 @@ function parseParts(values) {
|
|
|
121
184
|
}
|
|
122
185
|
return values;
|
|
123
186
|
}
|
|
187
|
+
function buildGenerateOptions(options) {
|
|
188
|
+
return {
|
|
189
|
+
methods: options.method,
|
|
190
|
+
middleware: options.middleware,
|
|
191
|
+
skipIndex: options.skipIndex,
|
|
192
|
+
dryRun: options.dryRun,
|
|
193
|
+
force: options.force,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
124
196
|
program.parse();
|
|
125
197
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,sDAAqD;AACrD,sDAAqD;AACrD,gEAAyF;AACzF,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,2BAAkC;AAClC,+BAA4B;AAC5B,yCAAoC;AACpC,sDAAqD;AACrD,sDAAqD;AACrD,8CAA8C;AAC9C,gEAAyF;AACzF,wDAAgE;AAChE,0DAAkD;AAClD,4DAA2F;AAE3F,yCAA6C;AAE7C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAAwB,CAAC;AAEzG,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAE/F,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,8CAA8C,CAAC;KAC3D,MAAM,CAAC,GAAG,EAAE;IACX,IAAI,CAAC;QACH,IAAA,yBAAO,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,sBAAsB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CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAA,oBAAY,EAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,OAAO,CAAC,CAAC,CAAC,qDAAqD,CAAC,CAAC;IACpG,CAAC;IAED,OAAO,MAAsB,CAAC;AAChC,CAAC;AAED,SAAS,oBAAoB,CAAC,OAM7B;IACC,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,MAAM;QACvB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC;AACJ,CAAC;AAED,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-method.d.ts","sourceRoot":"","sources":["../../src/commands/add-method.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAqC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"add-method.d.ts","sourceRoot":"","sources":["../../src/commands/add-method.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAqC,MAAM,eAAe,CAAC;AAOpF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAyC7F"}
|
|
@@ -4,26 +4,20 @@ exports.runAddMethod = runAddMethod;
|
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const config_1 = require("../utils/config");
|
|
7
|
+
const method_spec_1 = require("../utils/method-spec");
|
|
7
8
|
const naming_1 = require("../utils/naming");
|
|
8
9
|
const patch_method_1 = require("../utils/patch-method");
|
|
9
10
|
const parts_1 = require("../utils/parts");
|
|
10
|
-
const PATCHERS = {
|
|
11
|
-
controller: patch_method_1.patchControllerMethod,
|
|
12
|
-
service: patch_method_1.patchServiceMethod,
|
|
13
|
-
dto: patch_method_1.patchDtoMethod,
|
|
14
|
-
validator: patch_method_1.patchValidatorMethod,
|
|
15
|
-
routes: patch_method_1.patchRoutesMethod,
|
|
16
|
-
};
|
|
17
11
|
function runAddMethod(cwd, moduleName, options) {
|
|
18
12
|
const config = (0, config_1.loadConfig)(cwd);
|
|
19
13
|
const names = (0, naming_1.resolveModuleNames)(moduleName);
|
|
20
|
-
const methods = options.methods.map(
|
|
14
|
+
const methods = options.methods.map(method_spec_1.parseMethodSpec);
|
|
21
15
|
const targetDir = (0, path_1.join)(cwd, config.apiDir, names.kebab);
|
|
22
16
|
if (!(0, fs_1.existsSync)(targetDir)) {
|
|
23
17
|
throw new Error(`Module directory not found: ${targetDir}`);
|
|
24
18
|
}
|
|
25
19
|
const parts = options.parts.length > 0 ? options.parts : parts_1.MODULE_PARTS;
|
|
26
|
-
const ctx = { names, methods: [] };
|
|
20
|
+
const ctx = { names, methods: [], middleware: options.middleware };
|
|
27
21
|
const updated = [];
|
|
28
22
|
for (const part of parts) {
|
|
29
23
|
const filePath = (0, path_1.join)(targetDir, `${names.kebab}.${part}.ts`);
|
|
@@ -32,9 +26,14 @@ function runAddMethod(cwd, moduleName, options) {
|
|
|
32
26
|
}
|
|
33
27
|
let content = (0, fs_1.readFileSync)(filePath, "utf-8");
|
|
34
28
|
for (const method of methods) {
|
|
35
|
-
content = PATCHERS[part](content, ctx, method);
|
|
29
|
+
content = patch_method_1.PATCHERS[part](content, ctx, method);
|
|
30
|
+
}
|
|
31
|
+
if (options.dryRun) {
|
|
32
|
+
console.log(`[dry-run] patch ${filePath}`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
(0, fs_1.writeFileSync)(filePath, content, "utf-8");
|
|
36
36
|
}
|
|
37
|
-
(0, fs_1.writeFileSync)(filePath, content, "utf-8");
|
|
38
37
|
updated.push(filePath);
|
|
39
38
|
}
|
|
40
39
|
if (updated.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-method.js","sourceRoot":"","sources":["../../src/commands/add-method.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"add-method.js","sourceRoot":"","sources":["../../src/commands/add-method.ts"],"names":[],"mappings":";;AASA,oCAyCC;AAlDD,2BAA6D;AAC7D,+BAA4B;AAE5B,4CAA6C;AAC7C,sDAAuD;AACvD,4CAAqD;AACrD,wDAAiD;AACjD,0CAA8C;AAE9C,SAAgB,YAAY,CAAC,GAAW,EAAE,UAAkB,EAAE,OAAyB;IACrF,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,IAAA,2BAAkB,EAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,6BAAe,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,IAAA,WAAI,EAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAExD,IAAI,CAAC,IAAA,eAAU,EAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAY,CAAC;IACtE,MAAM,GAAG,GAA0B,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;IAC1F,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,GAAG,KAAK,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QAED,IAAI,OAAO,GAAG,IAAA,iBAAY,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,OAAO,GAAG,uBAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,IAAA,kBAAa,EAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,CAAC,KAAK,MAAM,CAAC,CAAC;IACtD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { CreateAppOptions } from "../interfaces";
|
|
2
|
+
export declare function runCreateApp(cwd: string, targetPath: string, options: CreateAppOptions): void;
|
|
2
3
|
//# sourceMappingURL=create-app.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../../src/commands/create-app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../../src/commands/create-app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAe7F"}
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.runCreateApp = runCreateApp;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const project_1 = require("../templates/project");
|
|
6
|
-
function runCreateApp(cwd, targetPath) {
|
|
6
|
+
function runCreateApp(cwd, targetPath, options) {
|
|
7
7
|
const targetDir = (0, path_1.resolve)(cwd, targetPath);
|
|
8
8
|
const projectName = (0, path_1.basename)(targetDir).replace(/[^a-z0-9-]/gi, "-").toLowerCase() || "express-api";
|
|
9
|
-
const written = (0, project_1.writeProjectFiles)(targetDir, projectName);
|
|
9
|
+
const written = (0, project_1.writeProjectFiles)(targetDir, projectName, options);
|
|
10
10
|
console.log(`Express API project created at ${targetDir}:\n`);
|
|
11
11
|
for (const file of written) {
|
|
12
12
|
console.log(` ${file}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../../src/commands/create-app.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../../src/commands/create-app.ts"],"names":[],"mappings":";;AAIA,oCAeC;AAnBD,+BAAyC;AAEzC,kDAAyD;AAEzD,SAAgB,YAAY,CAAC,GAAW,EAAE,UAAkB,EAAE,OAAyB;IACrF,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAA,eAAQ,EAAC,SAAS,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,IAAI,aAAa,CAAC;IACpG,MAAM,OAAO,GAAG,IAAA,2BAAiB,EAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAEnE,OAAO,CAAC,GAAG,CAAC,kCAAkC,SAAS,KAAK,CAAC,CAAC;IAC9D,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,UAAU,IAAI,CAAC;IAEhE,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM;;cAExB,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AASA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAqD3C"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runDoctor = runDoctor;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const config_1 = require("../utils/config");
|
|
7
|
+
function runDoctor(cwd) {
|
|
8
|
+
const config = (0, config_1.loadConfig)(cwd);
|
|
9
|
+
const checks = [];
|
|
10
|
+
checks.push({
|
|
11
|
+
ok: (0, fs_1.existsSync)((0, path_1.join)(cwd, ".bogorc.json")),
|
|
12
|
+
message: ".bogorc.json exists (optional, defaults are used if missing)",
|
|
13
|
+
});
|
|
14
|
+
checks.push({
|
|
15
|
+
ok: (0, fs_1.existsSync)((0, path_1.join)(cwd, config.indexFile)),
|
|
16
|
+
message: `index file exists: ${config.indexFile}`,
|
|
17
|
+
});
|
|
18
|
+
checks.push({
|
|
19
|
+
ok: (0, fs_1.existsSync)((0, path_1.join)(cwd, config.apiDir)),
|
|
20
|
+
message: `api directory exists: ${config.apiDir}`,
|
|
21
|
+
});
|
|
22
|
+
checks.push({
|
|
23
|
+
ok: (0, fs_1.existsSync)((0, path_1.join)(cwd, "src/middlewares/validate.ts")) || (0, fs_1.existsSync)((0, path_1.join)(cwd, "src/middlewares/validate.js")),
|
|
24
|
+
message: "validate middleware exists at src/middlewares/validate",
|
|
25
|
+
});
|
|
26
|
+
checks.push({
|
|
27
|
+
ok: (0, fs_1.existsSync)((0, path_1.join)(cwd, "src/middlewares/formatResponse.ts")) || (0, fs_1.existsSync)((0, path_1.join)(cwd, "src/middlewares/formatResponse.js")),
|
|
28
|
+
message: "formatResponse middleware exists at src/middlewares/formatResponse",
|
|
29
|
+
});
|
|
30
|
+
if (config.templatesDir) {
|
|
31
|
+
checks.push({
|
|
32
|
+
ok: (0, fs_1.existsSync)(config.templatesDir),
|
|
33
|
+
message: `custom templates directory exists: ${config.templatesDir}`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
console.log("bogo doctor\n");
|
|
37
|
+
let failed = 0;
|
|
38
|
+
for (const check of checks) {
|
|
39
|
+
const icon = check.ok ? "✓" : "✗";
|
|
40
|
+
console.log(` ${icon} ${check.message}`);
|
|
41
|
+
if (!check.ok) {
|
|
42
|
+
failed++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (failed > 0) {
|
|
46
|
+
console.log(`\n${failed} check(s) failed.`);
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.log("\nAll checks passed.");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@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,CAAC,CAAC;QAC5H,OAAO,EAAE,oEAAoE;KAC9E,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC;YACV,EAAE,EAAE,IAAA,eAAU,EAAC,MAAM,CAAC,YAAY,CAAC;YACnC,OAAO,EAAE,sCAAsC,MAAM,CAAC,YAAY,EAAE;SACrE,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7B,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACd,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC;IAED,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,mBAAmB,CAAC,CAAC;QAC5C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-module.d.ts","sourceRoot":"","sources":["../../src/commands/generate-module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAyB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-module.d.ts","sourceRoot":"","sources":["../../src/commands/generate-module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAyB,MAAM,eAAe,CAAC;AAsCzF,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAUzC;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAkBvG;AAED,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAWN"}
|