@ooneex/cli 1.17.10 → 1.18.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 +42 -22
- package/dist/index.js.map +6 -6
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5637,17 +5637,12 @@ class MakeModuleCommand {
|
|
|
5637
5637
|
const tsconfig = JSON.parse(content);
|
|
5638
5638
|
tsconfig.compilerOptions ??= {};
|
|
5639
5639
|
tsconfig.compilerOptions.paths ??= {};
|
|
5640
|
-
tsconfig.compilerOptions.paths[
|
|
5640
|
+
tsconfig.compilerOptions.paths[`@module/${kebabName}/*`] = [`../${kebabName}/src/*`];
|
|
5641
5641
|
await Bun.write(tsconfigPath, `${JSON.stringify(tsconfig, null, 2)}
|
|
5642
5642
|
`);
|
|
5643
5643
|
}
|
|
5644
5644
|
async run(options) {
|
|
5645
|
-
const {
|
|
5646
|
-
cwd = process.cwd(),
|
|
5647
|
-
silent = false,
|
|
5648
|
-
skipMigrations = false,
|
|
5649
|
-
skipSeeds = false
|
|
5650
|
-
} = options;
|
|
5645
|
+
const { cwd = process.cwd(), silent = false, skipMigrations = false, skipSeeds = false } = options;
|
|
5651
5646
|
let { name } = options;
|
|
5652
5647
|
if (!name) {
|
|
5653
5648
|
name = await askName({ message: "Enter module name" });
|
|
@@ -5680,6 +5675,13 @@ class MakeModuleCommand {
|
|
|
5680
5675
|
await this.addPathAlias(appTsconfigPath, kebabName);
|
|
5681
5676
|
}
|
|
5682
5677
|
}
|
|
5678
|
+
if (kebabName !== "app" && kebabName !== "shared") {
|
|
5679
|
+
const sharedModulePath = join5(cwd, "modules", "shared");
|
|
5680
|
+
if (await Bun.file(join5(sharedModulePath, "tsconfig.json")).exists()) {
|
|
5681
|
+
const moduleTsconfigPath = join5(moduleDir, "tsconfig.json");
|
|
5682
|
+
await this.addPathAlias(moduleTsconfigPath, "shared");
|
|
5683
|
+
}
|
|
5684
|
+
}
|
|
5683
5685
|
const commitlintPath = join5(cwd, ".commitlintrc.ts");
|
|
5684
5686
|
if (await Bun.file(commitlintPath).exists()) {
|
|
5685
5687
|
await this.addModuleScope(commitlintPath, kebabName);
|
|
@@ -6186,7 +6188,7 @@ import { TypeormDatabase, DatabaseException, decorator } from "@ooneex/database"
|
|
|
6186
6188
|
import { AppModule } from "@/AppModule";
|
|
6187
6189
|
|
|
6188
6190
|
@decorator.database()
|
|
6189
|
-
export class
|
|
6191
|
+
export class SharedDatabase extends TypeormDatabase {
|
|
6190
6192
|
constructor(@inject(AppEnv) private readonly env: AppEnv) {
|
|
6191
6193
|
super();
|
|
6192
6194
|
}
|
|
@@ -6614,7 +6616,7 @@ import { CorsMiddleware } from "@ooneex/middleware";
|
|
|
6614
6616
|
import { UpstashRedisRateLimiter } from "@ooneex/rate-limit";
|
|
6615
6617
|
import { BunnyStorage } from "@ooneex/storage";
|
|
6616
6618
|
import { AppModule } from "./AppModule";
|
|
6617
|
-
import {
|
|
6619
|
+
import { SharedDatabase } from "@module/shared/databases/SharedDatabase";
|
|
6618
6620
|
|
|
6619
6621
|
const app = new App({
|
|
6620
6622
|
routing: {
|
|
@@ -6631,7 +6633,7 @@ const app = new App({
|
|
|
6631
6633
|
cors: CorsMiddleware,
|
|
6632
6634
|
cronJobs: AppModule.cronJobs,
|
|
6633
6635
|
events: AppModule.events,
|
|
6634
|
-
database:
|
|
6636
|
+
database: SharedDatabase,
|
|
6635
6637
|
});
|
|
6636
6638
|
|
|
6637
6639
|
await app.run();
|
|
@@ -7015,8 +7017,15 @@ class MakeAppCommand {
|
|
|
7015
7017
|
const envContent = env_default.replace(/^DATABASE_URL=/m, 'DATABASE_URL="postgresql://ooneex:ooneex@localhost:5432/ooneex"').replace(/^CACHE_REDIS_URL=/m, 'CACHE_REDIS_URL="redis://localhost:6379"').replace(/^PUBSUB_REDIS_URL=/m, 'PUBSUB_REDIS_URL="redis://localhost:6379"').replace(/^RATE_LIMIT_REDIS_URL=/m, 'RATE_LIMIT_REDIS_URL="redis://localhost:6379"').replace(/^DATABASE_REDIS_URL=/m, 'DATABASE_REDIS_URL="redis://localhost:6379"');
|
|
7016
7018
|
await Bun.write(join9(destination, "modules", "app", ".env"), envContent);
|
|
7017
7019
|
await Bun.write(join9(destination, "modules", "app", ".env.example"), env_default);
|
|
7018
|
-
await Bun.write(join9(destination, "modules", "app", "src", "databases", "AppDatabase.ts"), app_database_default);
|
|
7019
7020
|
await Bun.write(join9(destination, "modules", "app", "src", "index.ts"), index_ts_default);
|
|
7021
|
+
await makeModuleCommand.run({
|
|
7022
|
+
name: "shared",
|
|
7023
|
+
cwd: destination,
|
|
7024
|
+
silent: true,
|
|
7025
|
+
skipMigrations: true,
|
|
7026
|
+
skipSeeds: true
|
|
7027
|
+
});
|
|
7028
|
+
await Bun.write(join9(destination, "modules", "shared", "src", "databases", "SharedDatabase.ts"), app_database_default);
|
|
7020
7029
|
const snakeName = toSnakeCase(name);
|
|
7021
7030
|
const dockerComposeContent = docker_compose_yml_default.replace(/{{NAME}}/g, snakeName);
|
|
7022
7031
|
await Bun.write(join9(destination, "modules", "app", "docker-compose.yml"), dockerComposeContent);
|
|
@@ -11214,9 +11223,20 @@ import { seedCreate } from "@ooneex/seeds";
|
|
|
11214
11223
|
// src/templates/module/seed.run.txt
|
|
11215
11224
|
var seed_run_default = `#!/usr/bin/env bun
|
|
11216
11225
|
|
|
11226
|
+
import { SharedDatabase } from "@module/shared/databases/SharedDatabase";
|
|
11227
|
+
import { AppEnv } from "@ooneex/app-env";
|
|
11228
|
+
import { container } from "@ooneex/container";
|
|
11217
11229
|
import { run } from "@ooneex/seeds";
|
|
11218
11230
|
import "@/seeds/seeds";
|
|
11219
11231
|
|
|
11232
|
+
if (!container.has(AppEnv)) {
|
|
11233
|
+
container.add(AppEnv);
|
|
11234
|
+
}
|
|
11235
|
+
if (!container.has(SharedDatabase)) {
|
|
11236
|
+
container.add(SharedDatabase);
|
|
11237
|
+
}
|
|
11238
|
+
container.addConstant("database", container.get(SharedDatabase));
|
|
11239
|
+
|
|
11220
11240
|
await run();
|
|
11221
11241
|
`;
|
|
11222
11242
|
|
|
@@ -11538,7 +11558,7 @@ class MigrationUpCommand {
|
|
|
11538
11558
|
logger.warn("No modules with migrations found", undefined, {
|
|
11539
11559
|
showTimestamp: false,
|
|
11540
11560
|
showArrow: false,
|
|
11541
|
-
useSymbol:
|
|
11561
|
+
useSymbol: false
|
|
11542
11562
|
});
|
|
11543
11563
|
return;
|
|
11544
11564
|
}
|
|
@@ -11557,7 +11577,7 @@ class MigrationUpCommand {
|
|
|
11557
11577
|
logger.warn("No modules with migrations found", undefined, {
|
|
11558
11578
|
showTimestamp: false,
|
|
11559
11579
|
showArrow: false,
|
|
11560
|
-
useSymbol:
|
|
11580
|
+
useSymbol: false
|
|
11561
11581
|
});
|
|
11562
11582
|
return;
|
|
11563
11583
|
}
|
|
@@ -11566,7 +11586,7 @@ class MigrationUpCommand {
|
|
|
11566
11586
|
logger.info(`Running migrations for ${name}...`, undefined, {
|
|
11567
11587
|
showTimestamp: false,
|
|
11568
11588
|
showArrow: false,
|
|
11569
|
-
useSymbol:
|
|
11589
|
+
useSymbol: false
|
|
11570
11590
|
});
|
|
11571
11591
|
const proc = Bun.spawn(["bun", "run", migrationUpPath], {
|
|
11572
11592
|
cwd: dir,
|
|
@@ -11578,13 +11598,13 @@ class MigrationUpCommand {
|
|
|
11578
11598
|
logger.success(`Migrations completed for ${name}`, undefined, {
|
|
11579
11599
|
showTimestamp: false,
|
|
11580
11600
|
showArrow: false,
|
|
11581
|
-
useSymbol:
|
|
11601
|
+
useSymbol: false
|
|
11582
11602
|
});
|
|
11583
11603
|
} else {
|
|
11584
11604
|
logger.error(`Migrations failed for ${name} (exit code: ${exitCode})`, undefined, {
|
|
11585
11605
|
showTimestamp: false,
|
|
11586
11606
|
showArrow: false,
|
|
11587
|
-
useSymbol:
|
|
11607
|
+
useSymbol: false
|
|
11588
11608
|
});
|
|
11589
11609
|
}
|
|
11590
11610
|
}
|
|
@@ -11612,7 +11632,7 @@ class SeedRunCommand {
|
|
|
11612
11632
|
logger.warn("No modules with seeds found", undefined, {
|
|
11613
11633
|
showTimestamp: false,
|
|
11614
11634
|
showArrow: false,
|
|
11615
|
-
useSymbol:
|
|
11635
|
+
useSymbol: false
|
|
11616
11636
|
});
|
|
11617
11637
|
return;
|
|
11618
11638
|
}
|
|
@@ -11631,7 +11651,7 @@ class SeedRunCommand {
|
|
|
11631
11651
|
logger.warn("No modules with seeds found", undefined, {
|
|
11632
11652
|
showTimestamp: false,
|
|
11633
11653
|
showArrow: false,
|
|
11634
|
-
useSymbol:
|
|
11654
|
+
useSymbol: false
|
|
11635
11655
|
});
|
|
11636
11656
|
return;
|
|
11637
11657
|
}
|
|
@@ -11640,7 +11660,7 @@ class SeedRunCommand {
|
|
|
11640
11660
|
logger.info(`Running seeds for ${name}...`, undefined, {
|
|
11641
11661
|
showTimestamp: false,
|
|
11642
11662
|
showArrow: false,
|
|
11643
|
-
useSymbol:
|
|
11663
|
+
useSymbol: false
|
|
11644
11664
|
});
|
|
11645
11665
|
const proc = Bun.spawn(["bun", "run", seedRunPath], {
|
|
11646
11666
|
cwd: dir,
|
|
@@ -11652,13 +11672,13 @@ class SeedRunCommand {
|
|
|
11652
11672
|
logger.success(`Seeds completed for ${name}`, undefined, {
|
|
11653
11673
|
showTimestamp: false,
|
|
11654
11674
|
showArrow: false,
|
|
11655
|
-
useSymbol:
|
|
11675
|
+
useSymbol: false
|
|
11656
11676
|
});
|
|
11657
11677
|
} else {
|
|
11658
11678
|
logger.error(`Seeds failed for ${name} (exit code: ${exitCode})`, undefined, {
|
|
11659
11679
|
showTimestamp: false,
|
|
11660
11680
|
showArrow: false,
|
|
11661
|
-
useSymbol:
|
|
11681
|
+
useSymbol: false
|
|
11662
11682
|
});
|
|
11663
11683
|
}
|
|
11664
11684
|
}
|
|
@@ -11670,4 +11690,4 @@ SeedRunCommand = __legacyDecorateClassTS([
|
|
|
11670
11690
|
// src/index.ts
|
|
11671
11691
|
await run();
|
|
11672
11692
|
|
|
11673
|
-
//# debugId=
|
|
11693
|
+
//# debugId=A91F5C1501E1122C64756E2164756E21
|