@ooneex/cli 1.17.9 → 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 +45 -50
- package/dist/index.js.map +8 -8
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -5637,18 +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
|
-
skipCommands = false
|
|
5651
|
-
} = options;
|
|
5645
|
+
const { cwd = process.cwd(), silent = false, skipMigrations = false, skipSeeds = false } = options;
|
|
5652
5646
|
let { name } = options;
|
|
5653
5647
|
if (!name) {
|
|
5654
5648
|
name = await askName({ message: "Enter module name" });
|
|
@@ -5668,9 +5662,6 @@ class MakeModuleCommand {
|
|
|
5668
5662
|
if (!skipSeeds) {
|
|
5669
5663
|
await Bun.write(join5(srcDir, "seeds", "seeds.ts"), "");
|
|
5670
5664
|
}
|
|
5671
|
-
if (!skipCommands) {
|
|
5672
|
-
await Bun.write(join5(srcDir, "commands", "commands.ts"), "");
|
|
5673
|
-
}
|
|
5674
5665
|
await Bun.write(join5(moduleDir, "package.json"), packageContent);
|
|
5675
5666
|
await Bun.write(join5(moduleDir, "tsconfig.json"), tsconfig_default);
|
|
5676
5667
|
await Bun.write(join5(testsDir, `${pascalName}Module.spec.ts`), testContent);
|
|
@@ -5684,6 +5675,13 @@ class MakeModuleCommand {
|
|
|
5684
5675
|
await this.addPathAlias(appTsconfigPath, kebabName);
|
|
5685
5676
|
}
|
|
5686
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
|
+
}
|
|
5687
5685
|
const commitlintPath = join5(cwd, ".commitlintrc.ts");
|
|
5688
5686
|
if (await Bun.file(commitlintPath).exists()) {
|
|
5689
5687
|
await this.addModuleScope(commitlintPath, kebabName);
|
|
@@ -6190,7 +6188,7 @@ import { TypeormDatabase, DatabaseException, decorator } from "@ooneex/database"
|
|
|
6190
6188
|
import { AppModule } from "@/AppModule";
|
|
6191
6189
|
|
|
6192
6190
|
@decorator.database()
|
|
6193
|
-
export class
|
|
6191
|
+
export class SharedDatabase extends TypeormDatabase {
|
|
6194
6192
|
constructor(@inject(AppEnv) private readonly env: AppEnv) {
|
|
6195
6193
|
super();
|
|
6196
6194
|
}
|
|
@@ -6618,7 +6616,7 @@ import { CorsMiddleware } from "@ooneex/middleware";
|
|
|
6618
6616
|
import { UpstashRedisRateLimiter } from "@ooneex/rate-limit";
|
|
6619
6617
|
import { BunnyStorage } from "@ooneex/storage";
|
|
6620
6618
|
import { AppModule } from "./AppModule";
|
|
6621
|
-
import {
|
|
6619
|
+
import { SharedDatabase } from "@module/shared/databases/SharedDatabase";
|
|
6622
6620
|
|
|
6623
6621
|
const app = new App({
|
|
6624
6622
|
routing: {
|
|
@@ -6635,7 +6633,7 @@ const app = new App({
|
|
|
6635
6633
|
cors: CorsMiddleware,
|
|
6636
6634
|
cronJobs: AppModule.cronJobs,
|
|
6637
6635
|
events: AppModule.events,
|
|
6638
|
-
database:
|
|
6636
|
+
database: SharedDatabase,
|
|
6639
6637
|
});
|
|
6640
6638
|
|
|
6641
6639
|
await app.run();
|
|
@@ -7019,8 +7017,15 @@ class MakeAppCommand {
|
|
|
7019
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"');
|
|
7020
7018
|
await Bun.write(join9(destination, "modules", "app", ".env"), envContent);
|
|
7021
7019
|
await Bun.write(join9(destination, "modules", "app", ".env.example"), env_default);
|
|
7022
|
-
await Bun.write(join9(destination, "modules", "app", "src", "databases", "AppDatabase.ts"), app_database_default);
|
|
7023
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);
|
|
7024
7029
|
const snakeName = toSnakeCase(name);
|
|
7025
7030
|
const dockerComposeContent = docker_compose_yml_default.replace(/{{NAME}}/g, snakeName);
|
|
7026
7031
|
await Bun.write(join9(destination, "modules", "app", "docker-compose.yml"), dockerComposeContent);
|
|
@@ -7038,6 +7043,7 @@ class MakeAppCommand {
|
|
|
7038
7043
|
"@ooneex/auth",
|
|
7039
7044
|
"@ooneex/cache",
|
|
7040
7045
|
"@ooneex/container",
|
|
7046
|
+
"@ooneex/repository",
|
|
7041
7047
|
"@ooneex/database",
|
|
7042
7048
|
"@ooneex/logger",
|
|
7043
7049
|
"@ooneex/mailer",
|
|
@@ -7066,6 +7072,8 @@ class MakeAppCommand {
|
|
|
7066
7072
|
"add",
|
|
7067
7073
|
"-D",
|
|
7068
7074
|
"@ooneex/command",
|
|
7075
|
+
"@ooneex/migrations",
|
|
7076
|
+
"@ooneex/seeds",
|
|
7069
7077
|
"@biomejs/biome",
|
|
7070
7078
|
"@commitlint/cli",
|
|
7071
7079
|
"@commitlint/config-conventional",
|
|
@@ -9552,24 +9560,12 @@ class MakeMigrationCommand {
|
|
|
9552
9560
|
if (!await binMigrationUpFile.exists()) {
|
|
9553
9561
|
await Bun.write(binMigrationUpPath, migration_up_default);
|
|
9554
9562
|
}
|
|
9555
|
-
const packageJsonPath = join21(process.cwd(), base, "package.json");
|
|
9556
9563
|
const logger = new TerminalLogger20;
|
|
9557
9564
|
logger.success(`${filePath} created successfully`, undefined, {
|
|
9558
9565
|
showTimestamp: false,
|
|
9559
9566
|
showArrow: false,
|
|
9560
9567
|
useSymbol: true
|
|
9561
9568
|
});
|
|
9562
|
-
const pkgJson = await Bun.file(packageJsonPath).json();
|
|
9563
|
-
const deps = pkgJson.dependencies ?? {};
|
|
9564
|
-
const devDeps = pkgJson.devDependencies ?? {};
|
|
9565
|
-
if (!deps["@ooneex/migrations"] && !devDeps["@ooneex/migrations"]) {
|
|
9566
|
-
const install = Bun.spawn(["bun", "add", "--dev", "@ooneex/migrations"], {
|
|
9567
|
-
cwd: process.cwd(),
|
|
9568
|
-
stdout: "ignore",
|
|
9569
|
-
stderr: "inherit"
|
|
9570
|
-
});
|
|
9571
|
-
await install.exited;
|
|
9572
|
-
}
|
|
9573
9569
|
}
|
|
9574
9570
|
}
|
|
9575
9571
|
MakeMigrationCommand = __legacyDecorateClassTS([
|
|
@@ -11227,9 +11223,20 @@ import { seedCreate } from "@ooneex/seeds";
|
|
|
11227
11223
|
// src/templates/module/seed.run.txt
|
|
11228
11224
|
var seed_run_default = `#!/usr/bin/env bun
|
|
11229
11225
|
|
|
11226
|
+
import { SharedDatabase } from "@module/shared/databases/SharedDatabase";
|
|
11227
|
+
import { AppEnv } from "@ooneex/app-env";
|
|
11228
|
+
import { container } from "@ooneex/container";
|
|
11230
11229
|
import { run } from "@ooneex/seeds";
|
|
11231
11230
|
import "@/seeds/seeds";
|
|
11232
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
|
+
|
|
11233
11240
|
await run();
|
|
11234
11241
|
`;
|
|
11235
11242
|
|
|
@@ -11260,7 +11267,6 @@ class MakeSeedCommand {
|
|
|
11260
11267
|
if (!await binSeedRunFile.exists()) {
|
|
11261
11268
|
await Bun.write(binSeedRunPath, seed_run_default);
|
|
11262
11269
|
}
|
|
11263
|
-
const packageJsonPath = join28(process.cwd(), base, "package.json");
|
|
11264
11270
|
const logger = new TerminalLogger26;
|
|
11265
11271
|
logger.success(`${filePath} created successfully`, undefined, {
|
|
11266
11272
|
showTimestamp: false,
|
|
@@ -11272,17 +11278,6 @@ class MakeSeedCommand {
|
|
|
11272
11278
|
showArrow: false,
|
|
11273
11279
|
useSymbol: true
|
|
11274
11280
|
});
|
|
11275
|
-
const pkgJson = await Bun.file(packageJsonPath).json();
|
|
11276
|
-
const deps = pkgJson.dependencies ?? {};
|
|
11277
|
-
const devDeps = pkgJson.devDependencies ?? {};
|
|
11278
|
-
if (!deps["@ooneex/seeds"] && !devDeps["@ooneex/seeds"]) {
|
|
11279
|
-
const install = Bun.spawn(["bun", "add", "--dev", "@ooneex/seeds"], {
|
|
11280
|
-
cwd: process.cwd(),
|
|
11281
|
-
stdout: "ignore",
|
|
11282
|
-
stderr: "inherit"
|
|
11283
|
-
});
|
|
11284
|
-
await install.exited;
|
|
11285
|
-
}
|
|
11286
11281
|
}
|
|
11287
11282
|
}
|
|
11288
11283
|
MakeSeedCommand = __legacyDecorateClassTS([
|
|
@@ -11563,7 +11558,7 @@ class MigrationUpCommand {
|
|
|
11563
11558
|
logger.warn("No modules with migrations found", undefined, {
|
|
11564
11559
|
showTimestamp: false,
|
|
11565
11560
|
showArrow: false,
|
|
11566
|
-
useSymbol:
|
|
11561
|
+
useSymbol: false
|
|
11567
11562
|
});
|
|
11568
11563
|
return;
|
|
11569
11564
|
}
|
|
@@ -11582,7 +11577,7 @@ class MigrationUpCommand {
|
|
|
11582
11577
|
logger.warn("No modules with migrations found", undefined, {
|
|
11583
11578
|
showTimestamp: false,
|
|
11584
11579
|
showArrow: false,
|
|
11585
|
-
useSymbol:
|
|
11580
|
+
useSymbol: false
|
|
11586
11581
|
});
|
|
11587
11582
|
return;
|
|
11588
11583
|
}
|
|
@@ -11591,7 +11586,7 @@ class MigrationUpCommand {
|
|
|
11591
11586
|
logger.info(`Running migrations for ${name}...`, undefined, {
|
|
11592
11587
|
showTimestamp: false,
|
|
11593
11588
|
showArrow: false,
|
|
11594
|
-
useSymbol:
|
|
11589
|
+
useSymbol: false
|
|
11595
11590
|
});
|
|
11596
11591
|
const proc = Bun.spawn(["bun", "run", migrationUpPath], {
|
|
11597
11592
|
cwd: dir,
|
|
@@ -11603,13 +11598,13 @@ class MigrationUpCommand {
|
|
|
11603
11598
|
logger.success(`Migrations completed for ${name}`, undefined, {
|
|
11604
11599
|
showTimestamp: false,
|
|
11605
11600
|
showArrow: false,
|
|
11606
|
-
useSymbol:
|
|
11601
|
+
useSymbol: false
|
|
11607
11602
|
});
|
|
11608
11603
|
} else {
|
|
11609
11604
|
logger.error(`Migrations failed for ${name} (exit code: ${exitCode})`, undefined, {
|
|
11610
11605
|
showTimestamp: false,
|
|
11611
11606
|
showArrow: false,
|
|
11612
|
-
useSymbol:
|
|
11607
|
+
useSymbol: false
|
|
11613
11608
|
});
|
|
11614
11609
|
}
|
|
11615
11610
|
}
|
|
@@ -11637,7 +11632,7 @@ class SeedRunCommand {
|
|
|
11637
11632
|
logger.warn("No modules with seeds found", undefined, {
|
|
11638
11633
|
showTimestamp: false,
|
|
11639
11634
|
showArrow: false,
|
|
11640
|
-
useSymbol:
|
|
11635
|
+
useSymbol: false
|
|
11641
11636
|
});
|
|
11642
11637
|
return;
|
|
11643
11638
|
}
|
|
@@ -11656,7 +11651,7 @@ class SeedRunCommand {
|
|
|
11656
11651
|
logger.warn("No modules with seeds found", undefined, {
|
|
11657
11652
|
showTimestamp: false,
|
|
11658
11653
|
showArrow: false,
|
|
11659
|
-
useSymbol:
|
|
11654
|
+
useSymbol: false
|
|
11660
11655
|
});
|
|
11661
11656
|
return;
|
|
11662
11657
|
}
|
|
@@ -11665,7 +11660,7 @@ class SeedRunCommand {
|
|
|
11665
11660
|
logger.info(`Running seeds for ${name}...`, undefined, {
|
|
11666
11661
|
showTimestamp: false,
|
|
11667
11662
|
showArrow: false,
|
|
11668
|
-
useSymbol:
|
|
11663
|
+
useSymbol: false
|
|
11669
11664
|
});
|
|
11670
11665
|
const proc = Bun.spawn(["bun", "run", seedRunPath], {
|
|
11671
11666
|
cwd: dir,
|
|
@@ -11677,13 +11672,13 @@ class SeedRunCommand {
|
|
|
11677
11672
|
logger.success(`Seeds completed for ${name}`, undefined, {
|
|
11678
11673
|
showTimestamp: false,
|
|
11679
11674
|
showArrow: false,
|
|
11680
|
-
useSymbol:
|
|
11675
|
+
useSymbol: false
|
|
11681
11676
|
});
|
|
11682
11677
|
} else {
|
|
11683
11678
|
logger.error(`Seeds failed for ${name} (exit code: ${exitCode})`, undefined, {
|
|
11684
11679
|
showTimestamp: false,
|
|
11685
11680
|
showArrow: false,
|
|
11686
|
-
useSymbol:
|
|
11681
|
+
useSymbol: false
|
|
11687
11682
|
});
|
|
11688
11683
|
}
|
|
11689
11684
|
}
|
|
@@ -11695,4 +11690,4 @@ SeedRunCommand = __legacyDecorateClassTS([
|
|
|
11695
11690
|
// src/index.ts
|
|
11696
11691
|
await run();
|
|
11697
11692
|
|
|
11698
|
-
//# debugId=
|
|
11693
|
+
//# debugId=A91F5C1501E1122C64756E2164756E21
|