@ooneex/cli 1.21.0 → 1.22.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/dist/index.js +200 -51
- package/dist/index.js.map +20 -19
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5178,7 +5178,7 @@ _oo_modules() {
|
|
|
5178
5178
|
_oo_custom_commands() {
|
|
5179
5179
|
local -a cmds
|
|
5180
5180
|
if [[ -d modules ]]; then
|
|
5181
|
-
cmds=(\${(@f)"$(command grep -rh
|
|
5181
|
+
cmds=(\${(@f)"$(command grep -rh -A1 'getName' modules/*/src/commands/*Command.ts 2>/dev/null | sed -n 's/.*return "\\(.*\\)".*/\\1/p' | sort -u)"})
|
|
5182
5182
|
compadd -a cmds
|
|
5183
5183
|
fi
|
|
5184
5184
|
}
|
|
@@ -5209,6 +5209,7 @@ _oo() {
|
|
|
5209
5209
|
'make\\:migration:Generate a new migration file'
|
|
5210
5210
|
'migration\\:up:Run migrations for all modules'
|
|
5211
5211
|
'make\\:module:Generate a new module'
|
|
5212
|
+
'remove\\:module:Remove an existing module'
|
|
5212
5213
|
'make\\:permission:Generate a new permission class'
|
|
5213
5214
|
'make\\:pubsub:Generate a new PubSub event class'
|
|
5214
5215
|
'make\\:release:Release packages with version bump, changelog, and git tag'
|
|
@@ -5289,6 +5290,10 @@ _oo() {
|
|
|
5289
5290
|
_arguments -s \\
|
|
5290
5291
|
'--name=[Name of the resource]:name'
|
|
5291
5292
|
;;
|
|
5293
|
+
remove:module)
|
|
5294
|
+
_arguments -s \\
|
|
5295
|
+
'--name=[Module name]:name:_oo_modules'
|
|
5296
|
+
;;
|
|
5292
5297
|
make:docker)
|
|
5293
5298
|
_arguments -s \\
|
|
5294
5299
|
'--name=[Docker service name]:name:(clickhouse elasticsearch grafana jaeger keycloak libretranslate maildev memcached minio mongodb mysql nats ooneex-jade postgres prometheus rabbitmq redis temporal vault)' \\
|
|
@@ -5332,7 +5337,7 @@ _ooneex_modules() {
|
|
|
5332
5337
|
_ooneex_custom_commands() {
|
|
5333
5338
|
local -a cmds
|
|
5334
5339
|
if [[ -d modules ]]; then
|
|
5335
|
-
cmds=(\${(@f)"$(command grep -rh
|
|
5340
|
+
cmds=(\${(@f)"$(command grep -rh -A1 'getName' modules/*/src/commands/*Command.ts 2>/dev/null | sed -n 's/.*return "\\(.*\\)".*/\\1/p' | sort -u)"})
|
|
5336
5341
|
compadd -a cmds
|
|
5337
5342
|
fi
|
|
5338
5343
|
}
|
|
@@ -5363,6 +5368,7 @@ _ooneex() {
|
|
|
5363
5368
|
'make\\:migration:Generate a new migration file'
|
|
5364
5369
|
'migration\\:up:Run migrations for all modules'
|
|
5365
5370
|
'make\\:module:Generate a new module'
|
|
5371
|
+
'remove\\:module:Remove an existing module'
|
|
5366
5372
|
'make\\:permission:Generate a new permission class'
|
|
5367
5373
|
'make\\:pubsub:Generate a new PubSub event class'
|
|
5368
5374
|
'make\\:release:Release packages with version bump, changelog, and git tag'
|
|
@@ -5443,6 +5449,10 @@ _ooneex() {
|
|
|
5443
5449
|
_arguments -s \\
|
|
5444
5450
|
'--name=[Name of the resource]:name'
|
|
5445
5451
|
;;
|
|
5452
|
+
remove:module)
|
|
5453
|
+
_arguments -s \\
|
|
5454
|
+
'--name=[Module name]:name:_ooneex_modules'
|
|
5455
|
+
;;
|
|
5446
5456
|
make:docker)
|
|
5447
5457
|
_arguments -s \\
|
|
5448
5458
|
'--name=[Docker service name]:name:(clickhouse elasticsearch grafana jaeger keycloak libretranslate maildev memcached minio mongodb mysql nats ooneex-jade postgres prometheus rabbitmq redis temporal vault)' \\
|
|
@@ -5598,7 +5608,7 @@ var askName = async (config) => {
|
|
|
5598
5608
|
|
|
5599
5609
|
// src/templates/ai.test.txt
|
|
5600
5610
|
var ai_test_default = `import { describe, expect, test } from "bun:test";
|
|
5601
|
-
import { {{NAME}}Ai } from "
|
|
5611
|
+
import { {{NAME}}Ai } from "@module/{{MODULE}}/ai/{{NAME}}Ai";
|
|
5602
5612
|
|
|
5603
5613
|
describe("{{NAME}}Ai", () => {
|
|
5604
5614
|
test("should have class name ending with 'Ai'", () => {
|
|
@@ -5867,7 +5877,7 @@ class MakeAiCommand {
|
|
|
5867
5877
|
const aiDir = join8(process.cwd(), aiLocalDir);
|
|
5868
5878
|
const filePath = join8(aiDir, `${name}Ai.ts`);
|
|
5869
5879
|
await Bun.write(filePath, content);
|
|
5870
|
-
const testContent = ai_test_default.replace(/{{NAME}}/g, name);
|
|
5880
|
+
const testContent = ai_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
5871
5881
|
const testsLocalDir = join8(base, "tests", "ai");
|
|
5872
5882
|
const testsDir = join8(process.cwd(), testsLocalDir);
|
|
5873
5883
|
const testFilePath = join8(testsDir, `${name}Ai.spec.ts`);
|
|
@@ -5908,7 +5918,7 @@ import { toPascalCase as toPascalCase3 } from "@ooneex/utils";
|
|
|
5908
5918
|
|
|
5909
5919
|
// src/templates/analytics.test.txt
|
|
5910
5920
|
var analytics_test_default = `import { describe, expect, test } from "bun:test";
|
|
5911
|
-
import { {{NAME}}Analytics } from "
|
|
5921
|
+
import { {{NAME}}Analytics } from "@module/{{MODULE}}/analytics/{{NAME}}Analytics";
|
|
5912
5922
|
|
|
5913
5923
|
describe("{{NAME}}Analytics", () => {
|
|
5914
5924
|
test("should have class name ending with 'Analytics'", () => {
|
|
@@ -5959,7 +5969,7 @@ class MakeAnalyticsCommand {
|
|
|
5959
5969
|
const analyticsDir = join9(process.cwd(), analyticsLocalDir);
|
|
5960
5970
|
const filePath = join9(analyticsDir, `${name}Analytics.ts`);
|
|
5961
5971
|
await Bun.write(filePath, content);
|
|
5962
|
-
const testContent = analytics_test_default.replace(/{{NAME}}/g, name);
|
|
5972
|
+
const testContent = analytics_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
5963
5973
|
const testsLocalDir = join9(base, "tests", "analytics");
|
|
5964
5974
|
const testsDir = join9(process.cwd(), testsLocalDir);
|
|
5965
5975
|
const testFilePath = join9(testsDir, `${name}Analytics.spec.ts`);
|
|
@@ -6316,11 +6326,11 @@ var/
|
|
|
6316
6326
|
`;
|
|
6317
6327
|
|
|
6318
6328
|
// src/templates/app/app-database.txt
|
|
6319
|
-
var app_database_default = `import {
|
|
6329
|
+
var app_database_default = `import { SharedModule } from "@module/shared/SharedModule";
|
|
6320
6330
|
import { AppEnv } from "@ooneex/app-env";
|
|
6331
|
+
import { inject } from "@ooneex/container";
|
|
6332
|
+
import { DatabaseException, decorator, TypeormDatabase } from "@ooneex/database";
|
|
6321
6333
|
import { DataSource } from "typeorm";
|
|
6322
|
-
import { TypeormDatabase, DatabaseException, decorator } from "@ooneex/database";
|
|
6323
|
-
import { SharedModule } from "@module/shared/SharedModule";
|
|
6324
6334
|
|
|
6325
6335
|
@decorator.database()
|
|
6326
6336
|
export class SharedDatabase extends TypeormDatabase {
|
|
@@ -6329,6 +6339,10 @@ export class SharedDatabase extends TypeormDatabase {
|
|
|
6329
6339
|
}
|
|
6330
6340
|
|
|
6331
6341
|
public getSource(): DataSource {
|
|
6342
|
+
if (this.source) {
|
|
6343
|
+
return this.source;
|
|
6344
|
+
}
|
|
6345
|
+
|
|
6332
6346
|
const url = this.env.DATABASE_URL;
|
|
6333
6347
|
|
|
6334
6348
|
if (!url) {
|
|
@@ -6339,13 +6353,21 @@ export class SharedDatabase extends TypeormDatabase {
|
|
|
6339
6353
|
}
|
|
6340
6354
|
|
|
6341
6355
|
this.source = new DataSource({
|
|
6356
|
+
type: "postgres",
|
|
6357
|
+
url,
|
|
6342
6358
|
synchronize: false,
|
|
6343
6359
|
entities: SharedModule.entities,
|
|
6360
|
+
poolSize: 10,
|
|
6344
6361
|
extra: {
|
|
6345
6362
|
max: 10,
|
|
6363
|
+
min: 2,
|
|
6364
|
+
idleTimeoutMillis: 30_000,
|
|
6365
|
+
connectionTimeoutMillis: 5_000,
|
|
6366
|
+
allowExitOnIdle: false,
|
|
6367
|
+
maxLifetimeSeconds: 1_800,
|
|
6346
6368
|
},
|
|
6347
|
-
|
|
6348
|
-
|
|
6369
|
+
logging: ["error", "warn", "migration"],
|
|
6370
|
+
maxQueryExecutionTime: 1_000,
|
|
6349
6371
|
});
|
|
6350
6372
|
|
|
6351
6373
|
return this.source;
|
|
@@ -7250,7 +7272,7 @@ import { toPascalCase as toPascalCase4 } from "@ooneex/utils";
|
|
|
7250
7272
|
|
|
7251
7273
|
// src/templates/cache.test.txt
|
|
7252
7274
|
var cache_test_default = `import { describe, expect, test } from "bun:test";
|
|
7253
|
-
import { {{NAME}}Cache } from "
|
|
7275
|
+
import { {{NAME}}Cache } from "@module/{{MODULE}}/cache/{{NAME}}Cache";
|
|
7254
7276
|
|
|
7255
7277
|
describe("{{NAME}}Cache", () => {
|
|
7256
7278
|
test("should have class name ending with 'Cache'", () => {
|
|
@@ -7326,7 +7348,7 @@ class MakeCacheCommand {
|
|
|
7326
7348
|
const cacheDir = join11(process.cwd(), cacheLocalDir);
|
|
7327
7349
|
const filePath = join11(cacheDir, `${name}Cache.ts`);
|
|
7328
7350
|
await Bun.write(filePath, content);
|
|
7329
|
-
const testContent = cache_test_default.replace(/{{NAME}}/g, name);
|
|
7351
|
+
const testContent = cache_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
7330
7352
|
const testsLocalDir = join11(base, "tests", "cache");
|
|
7331
7353
|
const testsDir = join11(process.cwd(), testsLocalDir);
|
|
7332
7354
|
const testFilePath = join11(testsDir, `${name}Cache.spec.ts`);
|
|
@@ -8030,7 +8052,7 @@ export class {{NAME}}Controller {
|
|
|
8030
8052
|
|
|
8031
8053
|
// src/templates/controller.test.txt
|
|
8032
8054
|
var controller_test_default = `import { describe, expect, test } from "bun:test";
|
|
8033
|
-
import { {{NAME}}Controller } from "
|
|
8055
|
+
import { {{NAME}}Controller } from "@module/{{MODULE}}/controllers/{{NAME}}Controller";
|
|
8034
8056
|
|
|
8035
8057
|
describe("{{NAME}}Controller", () => {
|
|
8036
8058
|
test("should have class name ending with 'Controller'", () => {
|
|
@@ -8156,7 +8178,7 @@ class MakeControllerCommand {
|
|
|
8156
8178
|
const controllersDir = join14(process.cwd(), controllersLocalDir);
|
|
8157
8179
|
const filePath = join14(controllersDir, `${name}Controller.ts`);
|
|
8158
8180
|
await Bun.write(filePath, content);
|
|
8159
|
-
const testContent = controller_test_default.replace(/{{NAME}}/g, name);
|
|
8181
|
+
const testContent = controller_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
8160
8182
|
const testsLocalDir = join14(base, "tests", "controllers");
|
|
8161
8183
|
const testsDir = join14(process.cwd(), testsLocalDir);
|
|
8162
8184
|
const testFilePath = join14(testsDir, `${name}Controller.spec.ts`);
|
|
@@ -8202,7 +8224,7 @@ import { toPascalCase as toPascalCase6 } from "@ooneex/utils";
|
|
|
8202
8224
|
|
|
8203
8225
|
// src/templates/cron.test.txt
|
|
8204
8226
|
var cron_test_default = `import { describe, expect, test } from "bun:test";
|
|
8205
|
-
import { {{NAME}}Cron } from "
|
|
8227
|
+
import { {{NAME}}Cron } from "@module/{{MODULE}}/cron/{{NAME}}Cron";
|
|
8206
8228
|
|
|
8207
8229
|
describe("{{NAME}}Cron", () => {
|
|
8208
8230
|
test("should have class name ending with 'Cron'", () => {
|
|
@@ -8291,7 +8313,7 @@ class MakeCronCommand {
|
|
|
8291
8313
|
const cronDir = join15(process.cwd(), cronLocalDir);
|
|
8292
8314
|
const filePath = join15(cronDir, `${name}Cron.ts`);
|
|
8293
8315
|
await Bun.write(filePath, content);
|
|
8294
|
-
const testContent = cron_test_default.replace(/{{NAME}}/g, name);
|
|
8316
|
+
const testContent = cron_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
8295
8317
|
const testsLocalDir = join15(base, "tests", "crons");
|
|
8296
8318
|
const testsDir = join15(process.cwd(), testsLocalDir);
|
|
8297
8319
|
const testFilePath = join15(testsDir, `${name}Cron.spec.ts`);
|
|
@@ -8337,7 +8359,7 @@ import { toPascalCase as toPascalCase7 } from "@ooneex/utils";
|
|
|
8337
8359
|
|
|
8338
8360
|
// src/templates/database.test.txt
|
|
8339
8361
|
var database_test_default = `import { describe, expect, test } from "bun:test";
|
|
8340
|
-
import { {{NAME}}Database } from "
|
|
8362
|
+
import { {{NAME}}Database } from "@module/{{MODULE}}/databases/{{NAME}}Database";
|
|
8341
8363
|
|
|
8342
8364
|
describe("{{NAME}}Database", () => {
|
|
8343
8365
|
test("should have class name ending with 'Database'", () => {
|
|
@@ -8400,7 +8422,7 @@ class MakeDatabaseCommand {
|
|
|
8400
8422
|
const databaseDir = join16(process.cwd(), databaseLocalDir);
|
|
8401
8423
|
const filePath = join16(databaseDir, `${name}Database.ts`);
|
|
8402
8424
|
await Bun.write(filePath, content);
|
|
8403
|
-
const testContent = database_test_default.replace(/{{NAME}}/g, name);
|
|
8425
|
+
const testContent = database_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
8404
8426
|
const testsLocalDir = join16(base, "tests", "databases");
|
|
8405
8427
|
const testsDir = join16(process.cwd(), testsLocalDir);
|
|
8406
8428
|
const testFilePath = join16(testsDir, `${name}Database.spec.ts`);
|
|
@@ -9022,7 +9044,7 @@ import { toPascalCase as toPascalCase8, toSnakeCase as toSnakeCase2 } from "@oon
|
|
|
9022
9044
|
|
|
9023
9045
|
// src/templates/entity.test.txt
|
|
9024
9046
|
var entity_test_default = `import { describe, expect, test } from "bun:test";
|
|
9025
|
-
import { {{NAME}}Entity } from "
|
|
9047
|
+
import { {{NAME}}Entity } from "@module/{{MODULE}}/entities/{{NAME}}Entity";
|
|
9026
9048
|
|
|
9027
9049
|
describe("{{NAME}}Entity", () => {
|
|
9028
9050
|
test("should have class name ending with 'Entity'", () => {
|
|
@@ -9186,7 +9208,7 @@ class MakeEntityCommand {
|
|
|
9186
9208
|
const entitiesDir = join18(process.cwd(), entitiesLocalDir);
|
|
9187
9209
|
const filePath = join18(entitiesDir, `${name}Entity.ts`);
|
|
9188
9210
|
await Bun.write(filePath, content);
|
|
9189
|
-
const testContent = entity_test_default.replace(/{{NAME}}/g, name);
|
|
9211
|
+
const testContent = entity_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
9190
9212
|
const testsLocalDir = join18(base, "tests", "entities");
|
|
9191
9213
|
const testsDir = join18(process.cwd(), testsLocalDir);
|
|
9192
9214
|
const testFilePath = join18(testsDir, `${name}Entity.spec.ts`);
|
|
@@ -9220,7 +9242,7 @@ import { toPascalCase as toPascalCase9 } from "@ooneex/utils";
|
|
|
9220
9242
|
|
|
9221
9243
|
// src/templates/logger.test.txt
|
|
9222
9244
|
var logger_test_default = `import { describe, expect, test } from "bun:test";
|
|
9223
|
-
import { {{NAME}}Logger } from "
|
|
9245
|
+
import { {{NAME}}Logger } from "@module/{{MODULE}}/loggers/{{NAME}}Logger";
|
|
9224
9246
|
|
|
9225
9247
|
describe("{{NAME}}Logger", () => {
|
|
9226
9248
|
test("should have class name ending with 'Logger'", () => {
|
|
@@ -9325,7 +9347,7 @@ class MakeLoggerCommand {
|
|
|
9325
9347
|
const loggerDir = join19(process.cwd(), loggerLocalDir);
|
|
9326
9348
|
const filePath = join19(loggerDir, `${name}Logger.ts`);
|
|
9327
9349
|
await Bun.write(filePath, content);
|
|
9328
|
-
const testContent = logger_test_default.replace(/{{NAME}}/g, name);
|
|
9350
|
+
const testContent = logger_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
9329
9351
|
const testsLocalDir = join19(base, "tests", "loggers");
|
|
9330
9352
|
const testsDir = join19(process.cwd(), testsLocalDir);
|
|
9331
9353
|
const testFilePath = join19(testsDir, `${name}Logger.spec.ts`);
|
|
@@ -9366,7 +9388,7 @@ import { toPascalCase as toPascalCase10 } from "@ooneex/utils";
|
|
|
9366
9388
|
|
|
9367
9389
|
// src/templates/mailer/mailer.test.txt
|
|
9368
9390
|
var mailer_test_default = `import { describe, expect, test } from "bun:test";
|
|
9369
|
-
import { {{NAME}}Mailer } from "
|
|
9391
|
+
import { {{NAME}}Mailer } from "@module/{{MODULE}}/mailers/{{NAME}}Mailer";
|
|
9370
9392
|
|
|
9371
9393
|
describe("{{NAME}}Mailer", () => {
|
|
9372
9394
|
test("should have class name ending with 'Mailer'", () => {
|
|
@@ -9409,7 +9431,7 @@ export class {{NAME}}Mailer implements IMailer {
|
|
|
9409
9431
|
|
|
9410
9432
|
// src/templates/mailer/mailer-template.test.txt
|
|
9411
9433
|
var mailer_template_test_default = `import { describe, expect, test } from "bun:test";
|
|
9412
|
-
import { {{NAME}}MailerTemplate } from "
|
|
9434
|
+
import { {{NAME}}MailerTemplate } from "@module/{{MODULE}}/mailers/{{NAME}}MailerTemplate";
|
|
9413
9435
|
|
|
9414
9436
|
describe("{{NAME}}MailerTemplate", () => {
|
|
9415
9437
|
test("should have function name ending with 'MailerTemplate'", () => {
|
|
@@ -9466,8 +9488,8 @@ class MakeMailerCommand {
|
|
|
9466
9488
|
const templateFilePath = join20(mailerDir, `${name}MailerTemplate.tsx`);
|
|
9467
9489
|
await Bun.write(mailerFilePath, mailerContent);
|
|
9468
9490
|
await Bun.write(templateFilePath, templateContent);
|
|
9469
|
-
const mailerTestContent = mailer_test_default.replace(/{{NAME}}/g, name);
|
|
9470
|
-
const templateTestContent = mailer_template_test_default.replace(/{{NAME}}/g, name);
|
|
9491
|
+
const mailerTestContent = mailer_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
9492
|
+
const templateTestContent = mailer_template_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
9471
9493
|
const testsLocalDir = join20(base, "tests", "mailers");
|
|
9472
9494
|
const testsDir = join20(process.cwd(), testsLocalDir);
|
|
9473
9495
|
const mailerTestFilePath = join20(testsDir, `${name}Mailer.spec.ts`);
|
|
@@ -9535,7 +9557,7 @@ export class {{NAME}}Middleware implements IMiddleware {
|
|
|
9535
9557
|
|
|
9536
9558
|
// src/templates/middleware.test.txt
|
|
9537
9559
|
var middleware_test_default = `import { describe, expect, test } from "bun:test";
|
|
9538
|
-
import { {{NAME}}Middleware } from "
|
|
9560
|
+
import { {{NAME}}Middleware } from "@module/{{MODULE}}/middlewares/{{NAME}}Middleware";
|
|
9539
9561
|
|
|
9540
9562
|
describe("{{NAME}}Middleware", () => {
|
|
9541
9563
|
test("should have class name ending with 'Middleware'", () => {
|
|
@@ -9609,7 +9631,7 @@ class MakeMiddlewareCommand {
|
|
|
9609
9631
|
const middlewareDir = join21(process.cwd(), middlewareLocalDir);
|
|
9610
9632
|
const filePath = join21(middlewareDir, `${name}Middleware.ts`);
|
|
9611
9633
|
await Bun.write(filePath, content);
|
|
9612
|
-
const testContent = middleware_test_default.replace(/{{NAME}}/g, name);
|
|
9634
|
+
const testContent = middleware_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
9613
9635
|
const testsLocalDir = join21(base, "tests", "middlewares");
|
|
9614
9636
|
const testsDir = join21(process.cwd(), testsLocalDir);
|
|
9615
9637
|
const testFilePath = join21(testsDir, `${name}Middleware.spec.ts`);
|
|
@@ -9708,7 +9730,7 @@ import { toPascalCase as toPascalCase12 } from "@ooneex/utils";
|
|
|
9708
9730
|
// src/templates/permission.test.txt
|
|
9709
9731
|
var permission_test_default = `import { describe, expect, test } from "bun:test";
|
|
9710
9732
|
import { Permission } from "@ooneex/permission";
|
|
9711
|
-
import { {{NAME}}Permission } from "
|
|
9733
|
+
import { {{NAME}}Permission } from "@module/{{MODULE}}/permissions/{{NAME}}Permission";
|
|
9712
9734
|
|
|
9713
9735
|
describe("{{NAME}}Permission", () => {
|
|
9714
9736
|
test("should have class name ending with 'Permission'", () => {
|
|
@@ -9798,7 +9820,7 @@ class MakePermissionCommand {
|
|
|
9798
9820
|
const permissionDir = join23(process.cwd(), permissionLocalDir);
|
|
9799
9821
|
const filePath = join23(permissionDir, `${name}Permission.ts`);
|
|
9800
9822
|
await Bun.write(filePath, content);
|
|
9801
|
-
const testContent = permission_test_default.replace(/{{NAME}}/g, name);
|
|
9823
|
+
const testContent = permission_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
9802
9824
|
const testsLocalDir = join23(base, "tests", "permissions");
|
|
9803
9825
|
const testsDir = join23(process.cwd(), testsLocalDir);
|
|
9804
9826
|
const testFilePath = join23(testsDir, `${name}Permission.spec.ts`);
|
|
@@ -9839,7 +9861,7 @@ import { toKebabCase as toKebabCase4, toPascalCase as toPascalCase13 } from "@oo
|
|
|
9839
9861
|
|
|
9840
9862
|
// src/templates/pubsub.test.txt
|
|
9841
9863
|
var pubsub_test_default = `import { describe, expect, test } from "bun:test";
|
|
9842
|
-
import { {{NAME}}PubSub } from "
|
|
9864
|
+
import { {{NAME}}PubSub } from "@module/{{MODULE}}/pubsub/{{NAME}}PubSub";
|
|
9843
9865
|
|
|
9844
9866
|
describe("{{NAME}}PubSub", () => {
|
|
9845
9867
|
test("should have class name ending with 'PubSub'", () => {
|
|
@@ -9947,7 +9969,7 @@ class MakePubSubCommand {
|
|
|
9947
9969
|
const pubSubDir = join24(process.cwd(), pubSubLocalDir);
|
|
9948
9970
|
const filePath = join24(pubSubDir, `${name}Event.ts`);
|
|
9949
9971
|
await Bun.write(filePath, content);
|
|
9950
|
-
const testContent = pubsub_test_default.replace(/{{NAME}}/g, name);
|
|
9972
|
+
const testContent = pubsub_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
9951
9973
|
const testsLocalDir = join24(base, "tests", "events");
|
|
9952
9974
|
const testsDir = join24(process.cwd(), testsLocalDir);
|
|
9953
9975
|
const testFilePath = join24(testsDir, `${name}Event.spec.ts`);
|
|
@@ -10238,7 +10260,7 @@ import { toPascalCase as toPascalCase14 } from "@ooneex/utils";
|
|
|
10238
10260
|
|
|
10239
10261
|
// src/templates/repository.test.txt
|
|
10240
10262
|
var repository_test_default = `import { describe, expect, test } from "bun:test";
|
|
10241
|
-
import { {{NAME}}Repository } from "
|
|
10263
|
+
import { {{NAME}}Repository } from "@module/{{MODULE}}/repositories/{{NAME}}Repository";
|
|
10242
10264
|
|
|
10243
10265
|
describe("{{NAME}}Repository", () => {
|
|
10244
10266
|
test("should have class name ending with 'Repository'", () => {
|
|
@@ -10452,7 +10474,7 @@ class MakeRepositoryCommand {
|
|
|
10452
10474
|
const repositoriesDir = join26(process.cwd(), repositoriesLocalDir);
|
|
10453
10475
|
const filePath = join26(repositoriesDir, `${name}Repository.ts`);
|
|
10454
10476
|
await Bun.write(filePath, content);
|
|
10455
|
-
const testContent = repository_test_default.replace(/{{NAME}}/g, name);
|
|
10477
|
+
const testContent = repository_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
10456
10478
|
const testsLocalDir = join26(base, "tests", "repositories");
|
|
10457
10479
|
const testsDir = join26(process.cwd(), testsLocalDir);
|
|
10458
10480
|
const testFilePath = join26(testsDir, `${name}Repository.spec.ts`);
|
|
@@ -11190,7 +11212,7 @@ import { toPascalCase as toPascalCase15 } from "@ooneex/utils";
|
|
|
11190
11212
|
|
|
11191
11213
|
// src/templates/service.test.txt
|
|
11192
11214
|
var service_test_default = `import { describe, expect, test } from "bun:test";
|
|
11193
|
-
import { {{NAME}}Service } from "
|
|
11215
|
+
import { {{NAME}}Service } from "@module/{{MODULE}}/services/{{NAME}}Service";
|
|
11194
11216
|
|
|
11195
11217
|
describe("{{NAME}}Service", () => {
|
|
11196
11218
|
test("should have class name ending with 'Service'", () => {
|
|
@@ -11242,7 +11264,7 @@ class MakeServiceCommand {
|
|
|
11242
11264
|
const serviceDir = join27(process.cwd(), serviceLocalDir);
|
|
11243
11265
|
const filePath = join27(serviceDir, `${name}Service.ts`);
|
|
11244
11266
|
await Bun.write(filePath, content);
|
|
11245
|
-
const testContent = service_test_default.replace(/{{NAME}}/g, name);
|
|
11267
|
+
const testContent = service_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
11246
11268
|
const testsLocalDir = join27(base, "tests", "services");
|
|
11247
11269
|
const testsDir = join27(process.cwd(), testsLocalDir);
|
|
11248
11270
|
const testFilePath = join27(testsDir, `${name}Service.spec.ts`);
|
|
@@ -21342,7 +21364,7 @@ import { toPascalCase as toPascalCase16, toSnakeCase as toSnakeCase3 } from "@oo
|
|
|
21342
21364
|
|
|
21343
21365
|
// src/templates/storage.test.txt
|
|
21344
21366
|
var storage_test_default = `import { describe, expect, test } from "bun:test";
|
|
21345
|
-
import { {{NAME}}StorageAdapter } from "
|
|
21367
|
+
import { {{NAME}}StorageAdapter } from "@module/{{MODULE}}/storage/{{NAME}}StorageAdapter";
|
|
21346
21368
|
|
|
21347
21369
|
describe("{{NAME}}StorageAdapter", () => {
|
|
21348
21370
|
test("should have class name ending with 'StorageAdapter'", () => {
|
|
@@ -21442,7 +21464,7 @@ class MakeStorageCommand {
|
|
|
21442
21464
|
const storageDir = join43(process.cwd(), storageLocalDir);
|
|
21443
21465
|
const filePath = join43(storageDir, `${name}Storage.ts`);
|
|
21444
21466
|
await Bun.write(filePath, content);
|
|
21445
|
-
const testContent = storage_test_default.replace(/{{NAME}}/g, name);
|
|
21467
|
+
const testContent = storage_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
21446
21468
|
const testsLocalDir = join43(base, "tests", "storage");
|
|
21447
21469
|
const testsDir = join43(process.cwd(), testsLocalDir);
|
|
21448
21470
|
const testFilePath = join43(testsDir, `${name}Storage.spec.ts`);
|
|
@@ -21483,7 +21505,7 @@ import { toPascalCase as toPascalCase17 } from "@ooneex/utils";
|
|
|
21483
21505
|
|
|
21484
21506
|
// src/templates/vector-database.test.txt
|
|
21485
21507
|
var vector_database_test_default = `import { describe, expect, test } from "bun:test";
|
|
21486
|
-
import { {{NAME}}VectorDatabase } from "
|
|
21508
|
+
import { {{NAME}}VectorDatabase } from "@module/{{MODULE}}/databases/{{NAME}}VectorDatabase";
|
|
21487
21509
|
|
|
21488
21510
|
describe("{{NAME}}VectorDatabase", () => {
|
|
21489
21511
|
test("should have class name ending with 'VectorDatabase'", () => {
|
|
@@ -21557,7 +21579,7 @@ class MakeVectorDatabaseCommand {
|
|
|
21557
21579
|
const vectorDatabaseDir = join44(process.cwd(), vectorDatabaseLocalDir);
|
|
21558
21580
|
const filePath = join44(vectorDatabaseDir, `${name}VectorDatabase.ts`);
|
|
21559
21581
|
await Bun.write(filePath, content);
|
|
21560
|
-
const testContent = vector_database_test_default.replace(/{{NAME}}/g, name);
|
|
21582
|
+
const testContent = vector_database_test_default.replace(/{{NAME}}/g, name).replace(/{{MODULE}}/g, module ?? "");
|
|
21561
21583
|
const testsLocalDir = join44(base, "tests", "databases");
|
|
21562
21584
|
const testsDir = join44(process.cwd(), testsLocalDir);
|
|
21563
21585
|
const testFilePath = join44(testsDir, `${name}VectorDatabase.spec.ts`);
|
|
@@ -21668,11 +21690,138 @@ class MigrationUpCommand {
|
|
|
21668
21690
|
MigrationUpCommand = __legacyDecorateClassTS([
|
|
21669
21691
|
decorator45.command()
|
|
21670
21692
|
], MigrationUpCommand);
|
|
21671
|
-
// src/commands/
|
|
21672
|
-
import {
|
|
21693
|
+
// src/commands/RemoveModuleCommand.ts
|
|
21694
|
+
import { rmdir } from "fs/promises";
|
|
21673
21695
|
import { join as join46 } from "path";
|
|
21674
21696
|
import { decorator as decorator46 } from "@ooneex/command";
|
|
21675
21697
|
import { TerminalLogger as TerminalLogger31 } from "@ooneex/logger";
|
|
21698
|
+
import { toKebabCase as toKebabCase5, toPascalCase as toPascalCase18 } from "@ooneex/utils";
|
|
21699
|
+
class RemoveModuleCommand {
|
|
21700
|
+
getName() {
|
|
21701
|
+
return "remove:module";
|
|
21702
|
+
}
|
|
21703
|
+
getDescription() {
|
|
21704
|
+
return "Remove an existing module";
|
|
21705
|
+
}
|
|
21706
|
+
async removeFromAppModule(appModulePath, pascalName, kebabName) {
|
|
21707
|
+
if (!await Bun.file(appModulePath).exists())
|
|
21708
|
+
return;
|
|
21709
|
+
let content = await Bun.file(appModulePath).text();
|
|
21710
|
+
const moduleName = `${pascalName}Module`;
|
|
21711
|
+
const importPath = `@module/${kebabName}/${moduleName}`;
|
|
21712
|
+
const importRegex = new RegExp(`import\\s*\\{\\s*${moduleName}\\s*\\}\\s*from\\s*"${importPath.replace(/\//g, "\\/")}";\\s*\\n`, "g");
|
|
21713
|
+
content = content.replace(importRegex, "");
|
|
21714
|
+
const fields = ["controllers", "middlewares", "cronJobs", "events"];
|
|
21715
|
+
for (const field of fields) {
|
|
21716
|
+
const spread = `...${moduleName}.${field}`;
|
|
21717
|
+
content = content.replace(new RegExp(`,\\s*${spread.replace(/\./g, "\\.")}`, "g"), "");
|
|
21718
|
+
content = content.replace(new RegExp(`${spread.replace(/\./g, "\\.")}\\s*,\\s*`, "g"), "");
|
|
21719
|
+
content = content.replace(new RegExp(`${spread.replace(/\./g, "\\.")}`, "g"), "");
|
|
21720
|
+
}
|
|
21721
|
+
await Bun.write(appModulePath, content);
|
|
21722
|
+
}
|
|
21723
|
+
async removeFromSharedModule(sharedModulePath, pascalName, kebabName) {
|
|
21724
|
+
if (!await Bun.file(sharedModulePath).exists())
|
|
21725
|
+
return;
|
|
21726
|
+
let content = await Bun.file(sharedModulePath).text();
|
|
21727
|
+
const moduleName = `${pascalName}Module`;
|
|
21728
|
+
const importPath = `@module/${kebabName}/${moduleName}`;
|
|
21729
|
+
const importRegex = new RegExp(`import\\s*\\{\\s*${moduleName}\\s*\\}\\s*from\\s*"${importPath.replace(/\//g, "\\/")}";\\s*\\n`, "g");
|
|
21730
|
+
content = content.replace(importRegex, "");
|
|
21731
|
+
const spread = `...${moduleName}.entities`;
|
|
21732
|
+
content = content.replace(new RegExp(`,\\s*${spread.replace(/\./g, "\\.")}`, "g"), "");
|
|
21733
|
+
content = content.replace(new RegExp(`${spread.replace(/\./g, "\\.")}\\s*,\\s*`, "g"), "");
|
|
21734
|
+
content = content.replace(new RegExp(`${spread.replace(/\./g, "\\.")}`, "g"), "");
|
|
21735
|
+
await Bun.write(sharedModulePath, content);
|
|
21736
|
+
}
|
|
21737
|
+
async removeModuleScope(commitlintPath, kebabName) {
|
|
21738
|
+
if (!await Bun.file(commitlintPath).exists())
|
|
21739
|
+
return;
|
|
21740
|
+
let content = await Bun.file(commitlintPath).text();
|
|
21741
|
+
const scope = `"${kebabName}"`;
|
|
21742
|
+
content = content.replace(new RegExp(`\\s*${scope.replace(/"/g, "\\\"")}\\s*,?`, "g"), "");
|
|
21743
|
+
content = content.replace(/,\s*,/g, ",");
|
|
21744
|
+
content = content.replace(/,(\s*\])/g, "$1");
|
|
21745
|
+
await Bun.write(commitlintPath, content);
|
|
21746
|
+
}
|
|
21747
|
+
async removePathAlias(tsconfigPath, kebabName) {
|
|
21748
|
+
if (!await Bun.file(tsconfigPath).exists())
|
|
21749
|
+
return;
|
|
21750
|
+
const content = await Bun.file(tsconfigPath).text();
|
|
21751
|
+
const tsconfig = JSON.parse(content);
|
|
21752
|
+
if (tsconfig.compilerOptions?.paths) {
|
|
21753
|
+
delete tsconfig.compilerOptions.paths[`@module/${kebabName}/*`];
|
|
21754
|
+
}
|
|
21755
|
+
await Bun.write(tsconfigPath, `${JSON.stringify(tsconfig, null, 2)}
|
|
21756
|
+
`);
|
|
21757
|
+
}
|
|
21758
|
+
async run(options) {
|
|
21759
|
+
const { cwd = process.cwd(), silent = false } = options;
|
|
21760
|
+
let { name } = options;
|
|
21761
|
+
if (!name) {
|
|
21762
|
+
name = await askName({ message: "Enter module name to remove" });
|
|
21763
|
+
}
|
|
21764
|
+
const pascalName = toPascalCase18(name).replace(/Module$/, "");
|
|
21765
|
+
const kebabName = toKebabCase5(pascalName);
|
|
21766
|
+
if (kebabName === "app" || kebabName === "shared") {
|
|
21767
|
+
if (!silent) {
|
|
21768
|
+
const logger = new TerminalLogger31;
|
|
21769
|
+
logger.error(`Cannot remove the "${kebabName}" module`, undefined, {
|
|
21770
|
+
showTimestamp: false,
|
|
21771
|
+
showArrow: false,
|
|
21772
|
+
useSymbol: true
|
|
21773
|
+
});
|
|
21774
|
+
}
|
|
21775
|
+
return;
|
|
21776
|
+
}
|
|
21777
|
+
const moduleDir = join46(cwd, "modules", kebabName);
|
|
21778
|
+
const moduleDirExists = await Bun.file(join46(moduleDir, "package.json")).exists();
|
|
21779
|
+
if (!moduleDirExists) {
|
|
21780
|
+
if (!silent) {
|
|
21781
|
+
const logger = new TerminalLogger31;
|
|
21782
|
+
logger.error(`Module "${kebabName}" does not exist`, undefined, {
|
|
21783
|
+
showTimestamp: false,
|
|
21784
|
+
showArrow: false,
|
|
21785
|
+
useSymbol: true
|
|
21786
|
+
});
|
|
21787
|
+
}
|
|
21788
|
+
return;
|
|
21789
|
+
}
|
|
21790
|
+
if (!silent) {
|
|
21791
|
+
const confirmed = await askConfirm({
|
|
21792
|
+
message: `Are you sure you want to remove the "${kebabName}" module?`,
|
|
21793
|
+
initial: false
|
|
21794
|
+
});
|
|
21795
|
+
if (!confirmed)
|
|
21796
|
+
return;
|
|
21797
|
+
}
|
|
21798
|
+
const appModulePath = join46(cwd, "modules", "app", "src", "AppModule.ts");
|
|
21799
|
+
await this.removeFromAppModule(appModulePath, pascalName, kebabName);
|
|
21800
|
+
const sharedModulePath = join46(cwd, "modules", "shared", "src", "SharedModule.ts");
|
|
21801
|
+
await this.removeFromSharedModule(sharedModulePath, pascalName, kebabName);
|
|
21802
|
+
const appTsconfigPath = join46(cwd, "tsconfig.json");
|
|
21803
|
+
await this.removePathAlias(appTsconfigPath, kebabName);
|
|
21804
|
+
const commitlintPath = join46(cwd, ".commitlintrc.ts");
|
|
21805
|
+
await this.removeModuleScope(commitlintPath, kebabName);
|
|
21806
|
+
await rmdir(moduleDir, { recursive: true });
|
|
21807
|
+
if (!silent) {
|
|
21808
|
+
const logger = new TerminalLogger31;
|
|
21809
|
+
logger.success(`modules/${kebabName} removed successfully`, undefined, {
|
|
21810
|
+
showTimestamp: false,
|
|
21811
|
+
showArrow: false,
|
|
21812
|
+
useSymbol: true
|
|
21813
|
+
});
|
|
21814
|
+
}
|
|
21815
|
+
}
|
|
21816
|
+
}
|
|
21817
|
+
RemoveModuleCommand = __legacyDecorateClassTS([
|
|
21818
|
+
decorator46.command()
|
|
21819
|
+
], RemoveModuleCommand);
|
|
21820
|
+
// src/commands/SeedRunCommand.ts
|
|
21821
|
+
import { existsSync as existsSync3 } from "fs";
|
|
21822
|
+
import { join as join47 } from "path";
|
|
21823
|
+
import { decorator as decorator47 } from "@ooneex/command";
|
|
21824
|
+
import { TerminalLogger as TerminalLogger32 } from "@ooneex/logger";
|
|
21676
21825
|
class SeedRunCommand {
|
|
21677
21826
|
getName() {
|
|
21678
21827
|
return "seed:run";
|
|
@@ -21681,8 +21830,8 @@ class SeedRunCommand {
|
|
|
21681
21830
|
return "Run seeds for all modules";
|
|
21682
21831
|
}
|
|
21683
21832
|
async run(options) {
|
|
21684
|
-
const logger = new
|
|
21685
|
-
const modulesDir =
|
|
21833
|
+
const logger = new TerminalLogger32;
|
|
21834
|
+
const modulesDir = join47(process.cwd(), "modules");
|
|
21686
21835
|
if (!existsSync3(modulesDir)) {
|
|
21687
21836
|
logger.warn("No modules with seeds found", undefined, {
|
|
21688
21837
|
showTimestamp: false,
|
|
@@ -21695,10 +21844,10 @@ class SeedRunCommand {
|
|
|
21695
21844
|
const modules = [];
|
|
21696
21845
|
for await (const match of glob.scan({ cwd: modulesDir, onlyFiles: true })) {
|
|
21697
21846
|
const entry = match.replace("/package.json", "");
|
|
21698
|
-
const moduleDir =
|
|
21699
|
-
const seedRunFile = Bun.file(
|
|
21847
|
+
const moduleDir = join47(modulesDir, entry);
|
|
21848
|
+
const seedRunFile = Bun.file(join47(moduleDir, "bin", "seed", "run.ts"));
|
|
21700
21849
|
if (await seedRunFile.exists()) {
|
|
21701
|
-
const packageJson = await Bun.file(
|
|
21850
|
+
const packageJson = await Bun.file(join47(modulesDir, match)).json();
|
|
21702
21851
|
modules.push({ name: packageJson.name ?? entry, dir: moduleDir });
|
|
21703
21852
|
}
|
|
21704
21853
|
}
|
|
@@ -21711,7 +21860,7 @@ class SeedRunCommand {
|
|
|
21711
21860
|
return;
|
|
21712
21861
|
}
|
|
21713
21862
|
for (const { name, dir } of modules) {
|
|
21714
|
-
const seedRunPath =
|
|
21863
|
+
const seedRunPath = join47(dir, "bin", "seed", "run.ts");
|
|
21715
21864
|
logger.info(`Running seeds for ${name}...`, undefined, {
|
|
21716
21865
|
showTimestamp: false,
|
|
21717
21866
|
showArrow: false,
|
|
@@ -21744,9 +21893,9 @@ class SeedRunCommand {
|
|
|
21744
21893
|
}
|
|
21745
21894
|
}
|
|
21746
21895
|
SeedRunCommand = __legacyDecorateClassTS([
|
|
21747
|
-
|
|
21896
|
+
decorator47.command()
|
|
21748
21897
|
], SeedRunCommand);
|
|
21749
21898
|
// src/index.ts
|
|
21750
21899
|
await run();
|
|
21751
21900
|
|
|
21752
|
-
//# debugId=
|
|
21901
|
+
//# debugId=1350E81FA9AB75E064756E2164756E21
|