@gravito/pulse 3.2.1 → 3.3.1

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.
Files changed (2) hide show
  1. package/dist/index.js +168 -35
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -83872,7 +83872,7 @@ var init_SchemaSniffer = __esm(() => {
83872
83872
  });
83873
83873
 
83874
83874
  // ../atlas/src/orm/schema/SchemaRegistry.ts
83875
- import { existsSync as existsSync3, readFileSync, writeFileSync } from "fs";
83875
+ import { existsSync as existsSync3, readFileSync as readFileSync2, writeFileSync } from "fs";
83876
83876
 
83877
83877
  class SchemaRegistry {
83878
83878
  static instance = null;
@@ -84002,7 +84002,7 @@ class SchemaRegistry {
84002
84002
  if (!existsSync3(lockPath)) {
84003
84003
  throw new Error(`Schema lock file not found: ${lockPath}. Run 'bun db:schema:lock' to generate.`);
84004
84004
  }
84005
- const content = readFileSync(lockPath, "utf-8");
84005
+ const content = readFileSync2(lockPath, "utf-8");
84006
84006
  const lock = JSON.parse(content);
84007
84007
  for (const [tableName, serialized] of Object.entries(lock.tables)) {
84008
84008
  const schema = this.deserializeTableSchema(serialized);
@@ -86404,6 +86404,11 @@ import { cancel as cancel4, intro as intro2, isCancel as isCancel5, note as note
86404
86404
  // ../scaffold/src/DependencyValidator.ts
86405
86405
  class DependencyValidator {
86406
86406
  static DRIVER_DEPENDENCIES = [
86407
+ {
86408
+ driver: "none",
86409
+ requiredPackages: [],
86410
+ description: "No database driver - developer to choose and install"
86411
+ },
86407
86412
  {
86408
86413
  driver: "redis",
86409
86414
  requiredPackages: ["@gravito/ion"],
@@ -86799,12 +86804,14 @@ class BaseGenerator {
86799
86804
  templateManager;
86800
86805
  fileMerger;
86801
86806
  filesCreated = [];
86807
+ context = null;
86802
86808
  constructor(config) {
86803
86809
  this.config = config;
86804
86810
  this.templateManager = new TemplateManager(config.templatesDir);
86805
86811
  this.fileMerger = new FileMerger;
86806
86812
  }
86807
86813
  async generate(context) {
86814
+ this.context = context;
86808
86815
  this.filesCreated = [];
86809
86816
  const structure = this.getDirectoryStructure(context);
86810
86817
  await this.createStructure(context.targetDir, structure, context);
@@ -86982,6 +86989,19 @@ Run \`bun run validate\` to check everything.
86982
86989
  }
86983
86990
  // ../scaffold/src/utils/ConfigGenerator.ts
86984
86991
  class ConfigGenerator {
86992
+ static generateDatabaseConfig(driver) {
86993
+ switch (driver) {
86994
+ case "none":
86995
+ return this.generateNoDatabaseConfig();
86996
+ case "sqlite":
86997
+ return this.generateSimpleDatabaseConfig();
86998
+ case "postgresql":
86999
+ case "mysql":
87000
+ return this.generateDetailedDatabaseConfig();
87001
+ default:
87002
+ return this.generateNoDatabaseConfig();
87003
+ }
87004
+ }
86985
87005
  static generateSimpleAppConfig(context) {
86986
87006
  return `export default {
86987
87007
  name: process.env.APP_NAME ?? '${context.name}',
@@ -87058,6 +87078,55 @@ export default {
87058
87078
  // 'AppServiceProvider',
87059
87079
  ],
87060
87080
  }
87081
+ `;
87082
+ }
87083
+ static generateNoDatabaseConfig() {
87084
+ return `/**
87085
+ * Database Configuration
87086
+ *
87087
+ * Configure your database connection below.
87088
+ * Choose one of the following drivers by installing the required package:
87089
+ *
87090
+ * SQLite: bun add better-sqlite3
87091
+ * PostgreSQL: bun add pg
87092
+ * MySQL: bun add mysql2
87093
+ */
87094
+ export default {
87095
+ default: process.env.DB_CONNECTION ?? 'sqlite',
87096
+
87097
+ connections: {
87098
+ sqlite: {
87099
+ driver: 'sqlite',
87100
+ database: process.env.DB_DATABASE ?? 'database/database.sqlite',
87101
+ },
87102
+
87103
+ postgresql: {
87104
+ driver: 'postgresql',
87105
+ host: process.env.DB_HOST ?? 'localhost',
87106
+ port: Number(process.env.DB_PORT ?? 5432),
87107
+ database: process.env.DB_DATABASE ?? 'forge',
87108
+ username: process.env.DB_USERNAME ?? 'forge',
87109
+ password: process.env.DB_PASSWORD ?? '',
87110
+ },
87111
+
87112
+ mysql: {
87113
+ driver: 'mysql',
87114
+ host: process.env.DB_HOST ?? 'localhost',
87115
+ port: Number(process.env.DB_PORT ?? 3306),
87116
+ database: process.env.DB_DATABASE ?? 'forge',
87117
+ username: process.env.DB_USERNAME ?? 'forge',
87118
+ password: process.env.DB_PASSWORD ?? '',
87119
+ },
87120
+ },
87121
+
87122
+ /**
87123
+ * Migration settings
87124
+ */
87125
+ migrations: {
87126
+ table: 'migrations',
87127
+ path: 'database/migrations',
87128
+ },
87129
+ }
87061
87130
  `;
87062
87131
  }
87063
87132
  static generateSimpleDatabaseConfig() {
@@ -87550,7 +87619,8 @@ class CleanArchitectureGenerator extends BaseGenerator {
87550
87619
  return ConfigGenerator.generateSimpleAppConfig(context);
87551
87620
  }
87552
87621
  generateDatabaseConfig() {
87553
- return ConfigGenerator.generateSimpleDatabaseConfig();
87622
+ const driver = this.context?.profileConfig?.drivers?.database ?? "none";
87623
+ return ConfigGenerator.generateDatabaseConfig(driver);
87554
87624
  }
87555
87625
  generateAuthConfig() {
87556
87626
  return ConfigGenerator.generateAuthConfig();
@@ -88142,7 +88212,9 @@ Created with \u2764\uFE0F using Gravito Framework
88142
88212
  }
88143
88213
  // ../scaffold/src/generators/ddd/BootstrapGenerator.ts
88144
88214
  class BootstrapGenerator {
88215
+ context = null;
88145
88216
  generate(context) {
88217
+ this.context = context;
88146
88218
  return {
88147
88219
  type: "directory",
88148
88220
  name: "Bootstrap",
@@ -88155,6 +88227,7 @@ class BootstrapGenerator {
88155
88227
  };
88156
88228
  }
88157
88229
  generateConfigDirectory(context) {
88230
+ this.context = context;
88158
88231
  return {
88159
88232
  type: "directory",
88160
88233
  name: "config",
@@ -88350,13 +88423,8 @@ export default {
88350
88423
  `;
88351
88424
  }
88352
88425
  generateDatabaseConfig() {
88353
- return `export default {
88354
- default: process.env.DB_CONNECTION ?? 'sqlite',
88355
- connections: {
88356
- sqlite: { driver: 'sqlite', database: 'database/database.sqlite' },
88357
- },
88358
- }
88359
- `;
88426
+ const driver = this.context?.profileConfig?.drivers?.database ?? "none";
88427
+ return ConfigGenerator.generateDatabaseConfig(driver);
88360
88428
  }
88361
88429
  generateCacheConfig() {
88362
88430
  return `export default {
@@ -89330,7 +89398,8 @@ describe('Example Test', () => {
89330
89398
  return ConfigGenerator.generateDetailedAppConfig(context);
89331
89399
  }
89332
89400
  generateDatabaseConfig() {
89333
- return ConfigGenerator.generateDetailedDatabaseConfig();
89401
+ const driver = this.context?.profileConfig?.drivers?.database ?? "none";
89402
+ return ConfigGenerator.generateDatabaseConfig(driver);
89334
89403
  }
89335
89404
  generateAuthConfig() {
89336
89405
  return `/**
@@ -90320,7 +90389,7 @@ class ProfileResolver {
90320
90389
  static DEFAULTS = {
90321
90390
  core: {
90322
90391
  drivers: {
90323
- database: "sqlite",
90392
+ database: "none",
90324
90393
  cache: "memory",
90325
90394
  queue: "sync",
90326
90395
  storage: "local",
@@ -90610,16 +90679,8 @@ describe('Example Test', () => {
90610
90679
  `;
90611
90680
  }
90612
90681
  generateDatabaseConfig() {
90613
- return `export default {
90614
- default: process.env.DB_CONNECTION ?? 'sqlite',
90615
- connections: {
90616
- sqlite: {
90617
- driver: 'sqlite',
90618
- database: process.env.DB_DATABASE ?? 'database/database.sqlite',
90619
- },
90620
- },
90621
- }
90622
- `;
90682
+ const driver = this.context?.profileConfig?.drivers?.database ?? "none";
90683
+ return ConfigGenerator.generateDatabaseConfig(driver);
90623
90684
  }
90624
90685
  generateUserModel() {
90625
90686
  return `/**
@@ -92584,7 +92645,7 @@ function registerInitCommand(cli) {
92584
92645
  }
92585
92646
 
92586
92647
  // src/commands/MakeCommand.ts
92587
- import { existsSync as existsSync2 } from "fs";
92648
+ import { existsSync as existsSync2, readFileSync } from "fs";
92588
92649
  import fs10 from "fs/promises";
92589
92650
  import path12 from "path";
92590
92651
  import { cancel as cancel2, isCancel as isCancel2, text as text2 } from "@clack/prompts";
@@ -92593,6 +92654,7 @@ var __dirname = "/Users/carl/Dev/Carl/gravito-core-ci-fix/packages/cli/src/comma
92593
92654
 
92594
92655
  class MakeCommand {
92595
92656
  searchPaths = [];
92657
+ architecture = "mvc";
92596
92658
  constructor(customStubsPath) {
92597
92659
  const cwd = process.cwd();
92598
92660
  const devPath = path12.resolve(__dirname, "../../stubs");
@@ -92602,6 +92664,17 @@ class MakeCommand {
92602
92664
  }
92603
92665
  this.searchPaths.push(path12.resolve(cwd, "stubs"), path12.resolve(cwd, ".gravito/stubs"), prodPath, devPath, path12.resolve(cwd, "packages/cli/stubs"), path12.resolve(cwd, "../packages/cli/stubs"));
92604
92666
  this.searchPaths = this.searchPaths.filter((p) => existsSync2(p));
92667
+ this.detectArchitecture();
92668
+ }
92669
+ detectArchitecture() {
92670
+ try {
92671
+ const pkgPath = path12.join(process.cwd(), "package.json");
92672
+ const content = readFileSync(pkgPath, "utf-8");
92673
+ const pkg = JSON.parse(content);
92674
+ this.architecture = pkg.gravito?.architecture || "mvc";
92675
+ } catch {
92676
+ this.architecture = "mvc";
92677
+ }
92605
92678
  }
92606
92679
  async run(type, name, options = {}) {
92607
92680
  let resolvedName = name;
@@ -92699,18 +92772,40 @@ class MakeCommand {
92699
92772
  }
92700
92773
  resolveTargetPath(type, name) {
92701
92774
  const cwd = process.cwd();
92702
- const map = {
92703
- controller: `src/controllers/${name.pascal}Controller.ts`,
92704
- model: `src/models/${name.pascal}.ts`,
92705
- middleware: `src/middleware/${name.camel}.ts`,
92706
- seeder: `src/database/seeders/${name.pascal}Seeder.ts`,
92707
- request: `src/requests/${name.pascal}Request.ts`,
92708
- command: `src/commands/${name.pascal}Command.ts`
92775
+ const architecturePaths = {
92776
+ mvc: {
92777
+ controller: `src/Http/Controllers/${name.pascal}Controller.ts`,
92778
+ model: `src/Models/${name.pascal}.ts`,
92779
+ middleware: `src/Http/Middleware/${name.pascal}Middleware.ts`,
92780
+ seeder: `database/seeders/${name.pascal}Seeder.ts`,
92781
+ request: `src/Http/Requests/${name.pascal}Request.ts`,
92782
+ command: `src/Commands/${name.pascal}Command.ts`,
92783
+ service: `src/Services/${name.pascal}Service.ts`
92784
+ },
92785
+ ddd: {
92786
+ controller: `src/Presentation/Http/Controllers/${name.pascal}Controller.ts`,
92787
+ model: `src/Domain/${name.pascal}.ts`,
92788
+ middleware: `src/Presentation/Http/Middleware/${name.pascal}Middleware.ts`,
92789
+ seeder: `database/seeders/${name.pascal}Seeder.ts`,
92790
+ request: `src/Presentation/Http/Requests/${name.pascal}Request.ts`,
92791
+ command: `src/Application/Commands/${name.pascal}Command.ts`,
92792
+ service: `src/Application/Services/${name.pascal}Service.ts`
92793
+ },
92794
+ cqrs: {
92795
+ controller: `src/Presentation/Controllers/${name.pascal}Controller.ts`,
92796
+ model: `src/Infrastructure/Persistence/${name.pascal}.ts`,
92797
+ middleware: `src/Presentation/Middleware/${name.pascal}Middleware.ts`,
92798
+ seeder: `database/seeders/${name.pascal}Seeder.ts`,
92799
+ request: `src/Presentation/Requests/${name.pascal}Request.ts`,
92800
+ command: `src/Application/Commands/${name.pascal}Command.ts`,
92801
+ service: `src/Application/Services/${name.pascal}Service.ts`
92802
+ }
92709
92803
  };
92710
- if (!map[type]) {
92711
- throw new Error(`Unknown type: ${type}`);
92804
+ const paths = architecturePaths[this.architecture];
92805
+ if (!paths || !paths[type]) {
92806
+ throw new Error(`Unknown type: ${type} for architecture: ${this.architecture}`);
92712
92807
  }
92713
- return path12.join(cwd, map[type]);
92808
+ return path12.join(cwd, paths[type]);
92714
92809
  }
92715
92810
  normalizeName(type, rawName) {
92716
92811
  const pascalRaw = this.toPascalCase(rawName);
@@ -94482,7 +94577,9 @@ cli.command("schedule:list", "List scheduled tasks").option("--entry <file>", "E
94482
94577
  process.exit(1);
94483
94578
  }
94484
94579
  });
94485
- cli.command("create [name]", "Create a new Gravito project").option("--template <template>", "Template to use (basic, inertia-react)").option("--profile <profile>", "Profile preset (core, scale, enterprise)", { default: "core" }).option("--with <features>", "Feature add-ons (comma-separated, e.g. redis,queue)", {
94580
+ cli.command("create [name]", "Create a new Gravito project").option("--architecture <arch>", "Architecture pattern (mvc, ddd, cqrs)", {
94581
+ default: "mvc"
94582
+ }).option("--template <template>", "Template to use (basic, inertia-react)").option("--profile <profile>", "Profile preset (core, scale, enterprise)", { default: "core" }).option("--with <features>", "Feature add-ons (comma-separated, e.g. redis,queue)", {
94486
94583
  default: ""
94487
94584
  }).option("--recommend", "Auto-detect profile based on environment").option("--framework <framework>", "Frontend framework (react, vue) for static-site template").action(async (name, options) => {
94488
94585
  console.clear();
@@ -94526,6 +94623,17 @@ Confidence: ${detection.confidence}`, "Environment Detection");
94526
94623
  console.log(pc14.gray(`Available features: redis, postgres, mysql, s3, queue, monitor...`));
94527
94624
  process.exit(1);
94528
94625
  }
94626
+ const validArchitectures = ["mvc", "ddd", "cqrs"];
94627
+ if (!validArchitectures.includes(options.architecture)) {
94628
+ console.error(pc14.red(`\u274C Invalid architecture: ${options.architecture}`));
94629
+ console.log(pc14.gray(`Available architectures: ${validArchitectures.join(", ")}`));
94630
+ process.exit(1);
94631
+ }
94632
+ const ARCHITECTURE_TEMPLATES = {
94633
+ mvc: "mvc-starter",
94634
+ ddd: "ddd-starter",
94635
+ cqrs: "cqrs-starter"
94636
+ };
94529
94637
  const project = await group({
94530
94638
  name: () => {
94531
94639
  if (name) {
@@ -94550,9 +94658,30 @@ Confidence: ${detection.confidence}`, "Environment Detection");
94550
94658
  if (options.template) {
94551
94659
  return Promise.resolve(options.template);
94552
94660
  }
94661
+ if (options.architecture && options.architecture !== "mvc") {
94662
+ const template = ARCHITECTURE_TEMPLATES[options.architecture];
94663
+ if (template) {
94664
+ return Promise.resolve(template);
94665
+ }
94666
+ }
94553
94667
  return select2({
94554
94668
  message: "Pick a starting point:",
94555
94669
  options: [
94670
+ {
94671
+ value: "mvc-starter",
94672
+ label: "\uD83C\uDFD7\uFE0F MVC (Recommended)",
94673
+ hint: "Traditional MVC for CRUD apps"
94674
+ },
94675
+ {
94676
+ value: "ddd-starter",
94677
+ label: "\uD83E\uDDE9 DDD",
94678
+ hint: "Domain-Driven Design for complex business logic"
94679
+ },
94680
+ {
94681
+ value: "cqrs-starter",
94682
+ label: "\u26A1 CQRS",
94683
+ hint: "Command Query Responsibility Segregation for high-concurrency"
94684
+ },
94556
94685
  {
94557
94686
  value: "basic",
94558
94687
  label: "\uD83D\uDE80 Singularity (Light)",
@@ -94857,6 +94986,10 @@ Confidence: ${detection.confidence}`, "Environment Detection");
94857
94986
  const pkgPath = path22.join(process.cwd(), targetDir, "package.json");
94858
94987
  const pkg = JSON.parse(await fs19.readFile(pkgPath, "utf-8"));
94859
94988
  pkg.name = packageName.toLowerCase().replace(/[^a-z0-9-_]/g, "-");
94989
+ if (!pkg.gravito) {
94990
+ pkg.gravito = {};
94991
+ }
94992
+ pkg.gravito.architecture = options.architecture;
94860
94993
  s.start("\u8F09\u5165 package \u7248\u672C\u8CC7\u8A0A...");
94861
94994
  const versionRegistry = new VersionRegistry;
94862
94995
  await versionRegistry.initialize();
@@ -95255,7 +95388,7 @@ cli.command("dev", "Start development server with health checks").action(async (
95255
95388
  });
95256
95389
  });
95257
95390
  cli.help();
95258
- cli.version("3.2.0");
95391
+ cli.version("3.3.0");
95259
95392
  async function loadPlugins(cli2) {
95260
95393
  try {
95261
95394
  const cwd = process.cwd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravito/pulse",
3
- "version": "3.2.1",
3
+ "version": "3.3.1",
4
4
  "description": "The official CLI for Gravito Galaxy Architecture. Scaffold projects and manage your universe.",
5
5
  "bin": {
6
6
  "gravito": "bin/gravito.mjs"
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@clack/prompts": "^0.7.0",
30
- "@gravito/scaffold": "^3.1.1",
30
+ "@gravito/scaffold": "^4.0.0",
31
31
  "cac": "^6.7.14",
32
32
  "giget": "^1.2.5",
33
33
  "node-fetch-native": "^1.6.7",