@famgia/omnify-laravel 0.0.147 → 0.0.149

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.
@@ -1,6 +1,6 @@
1
1
  // src/plugin.ts
2
- import { readFileSync as readFileSync2, existsSync as existsSync2, readdirSync as readdirSync2 } from "fs";
3
- import { join as join2 } from "path";
2
+ import { readFileSync, existsSync as existsSync2, readdirSync as readdirSync2 } from "fs";
3
+ import { join } from "path";
4
4
 
5
5
  // src/migration/schema-builder.ts
6
6
  import { resolveLocalizedString } from "@famgia/omnify-types";
@@ -2406,7 +2406,6 @@ class {{CLASS_NAME}} extends {{CLASS_NAME}}BaseModel
2406
2406
 
2407
2407
  namespace App\\Providers;
2408
2408
 
2409
- use App\\Support\\Omnify;
2410
2409
  use Illuminate\\Database\\Eloquent\\Relations\\Relation;
2411
2410
  use Illuminate\\Support\\ServiceProvider;
2412
2411
 
@@ -2418,7 +2417,6 @@ use Illuminate\\Support\\ServiceProvider;
2418
2417
  *
2419
2418
  * - Loads Omnify migrations from database/migrations/omnify
2420
2419
  * - Registers morph map for polymorphic relationships
2421
- * - Exports schema paths for CLI consumption
2422
2420
  *
2423
2421
  * @generated by @famgia/omnify-laravel
2424
2422
  */
@@ -2444,11 +2442,6 @@ class OmnifyServiceProvider extends ServiceProvider
2444
2442
  Relation::enforceMorphMap([
2445
2443
  {{MORPH_MAP}}
2446
2444
  ]);
2447
-
2448
- // Export registered schema paths for CLI (only when running artisan commands)
2449
- if ($this->app->runningInConsole()) {
2450
- Omnify::exportPaths();
2451
- }
2452
2445
  }
2453
2446
  }
2454
2447
  `,
@@ -2577,148 +2570,6 @@ class {{CLASS_NAME}}Locales
2577
2570
  {{LOCALIZED_PROPERTY_DISPLAY_NAMES}}
2578
2571
  ];
2579
2572
  }
2580
- `,
2581
- "omnify-support": `<?php
2582
-
2583
- namespace App\\Support;
2584
-
2585
- /**
2586
- * Omnify Support Class
2587
- *
2588
- * Allows Laravel packages to register their schema directories.
2589
- *
2590
- * DO NOT EDIT - This file is auto-generated by Omnify.
2591
- * Any changes will be overwritten on next generation.
2592
- *
2593
- * @example
2594
- * // In your package's ServiceProvider:
2595
- * use App\\Support\\Omnify;
2596
- *
2597
- * public function boot()
2598
- * {
2599
- * Omnify::addSchemaPath(__DIR__.'/../database/schemas');
2600
- * }
2601
- *
2602
- * @generated by @famgia/omnify-laravel
2603
- */
2604
- class Omnify
2605
- {
2606
- /**
2607
- * Registered schema paths from packages.
2608
- *
2609
- * @var array<array{path: string, namespace: string|null}>
2610
- */
2611
- protected static array $schemaPaths = [];
2612
-
2613
- /**
2614
- * Register a schema directory path.
2615
- *
2616
- * @param string $path Absolute path to schema directory
2617
- * @param string|null $namespace Optional namespace prefix for schemas
2618
- * @return void
2619
- */
2620
- public static function addSchemaPath(string $path, ?string $namespace = null): void
2621
- {
2622
- $realPath = realpath($path);
2623
-
2624
- if ($realPath === false) {
2625
- $realPath = $path;
2626
- }
2627
-
2628
- static::$schemaPaths[] = [
2629
- 'path' => $realPath,
2630
- 'namespace' => $namespace,
2631
- ];
2632
- }
2633
-
2634
- /**
2635
- * Get all registered schema paths.
2636
- *
2637
- * @return array<array{path: string, namespace: string|null}>
2638
- */
2639
- public static function getSchemaPaths(): array
2640
- {
2641
- return static::$schemaPaths;
2642
- }
2643
-
2644
- /**
2645
- * Clear all registered schema paths.
2646
- */
2647
- public static function clearSchemaPaths(): void
2648
- {
2649
- static::$schemaPaths = [];
2650
- }
2651
-
2652
- /**
2653
- * Export schema paths to JSON file for CLI consumption.
2654
- *
2655
- * @param string|null $outputPath Path to write JSON file
2656
- * @return string Path to the generated file
2657
- */
2658
- public static function exportPaths(?string $outputPath = null): string
2659
- {
2660
- $outputPath = $outputPath ?? storage_path('omnify/schema-paths.json');
2661
-
2662
- $dir = dirname($outputPath);
2663
- if (!is_dir($dir)) {
2664
- mkdir($dir, 0755, true);
2665
- }
2666
-
2667
- $data = [
2668
- 'generated_at' => date('c'),
2669
- 'paths' => static::$schemaPaths,
2670
- ];
2671
-
2672
- file_put_contents($outputPath, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
2673
-
2674
- return $outputPath;
2675
- }
2676
- }
2677
- `,
2678
- "omnify-command": `<?php
2679
-
2680
- namespace App\\Console\\Commands;
2681
-
2682
- use App\\Support\\Omnify;
2683
- use Illuminate\\Console\\Command;
2684
-
2685
- /**
2686
- * Sync registered schema paths for Omnify CLI.
2687
- *
2688
- * DO NOT EDIT - This file is auto-generated by Omnify.
2689
- * Any changes will be overwritten on next generation.
2690
- *
2691
- * @generated by @famgia/omnify-laravel
2692
- */
2693
- class OmnifySyncCommand extends Command
2694
- {
2695
- protected $signature = 'omnify:sync {--output= : Custom output path}';
2696
-
2697
- protected $description = 'Export registered schema paths for Omnify CLI';
2698
-
2699
- public function handle(): int
2700
- {
2701
- $this->info('Syncing Omnify schema paths...');
2702
-
2703
- $paths = Omnify::getSchemaPaths();
2704
-
2705
- if (empty($paths)) {
2706
- $this->warn('No additional schema paths registered.');
2707
- $this->line('Tip: Packages can use Omnify::addSchemaPath()');
2708
- } else {
2709
- $this->line('Found ' . count($paths) . ' path(s):');
2710
- foreach ($paths as $entry) {
2711
- $ns = $entry['namespace'] ? " [{$entry['namespace']}]" : '';
2712
- $this->line(" \u2022 {$entry['path']}{$ns}");
2713
- }
2714
- }
2715
-
2716
- $filePath = Omnify::exportPaths($this->option('output'));
2717
- $this->info("\u2713 Exported to: {$filePath}");
2718
-
2719
- return Command::SUCCESS;
2720
- }
2721
- }
2722
2573
  `
2723
2574
  };
2724
2575
  return stubs[stubName] ?? "";
@@ -2749,30 +2600,6 @@ function generateLocalizedDisplayNameTrait(options, stubContent) {
2749
2600
  schemaName: "__trait__"
2750
2601
  };
2751
2602
  }
2752
- function generateOmnifySupport(options, stubContent) {
2753
- const appPath = options.modelPath.replace(/\/Models$/, "");
2754
- return {
2755
- path: `${appPath}/Support/Omnify.php`,
2756
- content: stubContent,
2757
- type: "trait",
2758
- // Use trait type for support classes
2759
- overwrite: true,
2760
- // Always overwrite
2761
- schemaName: "__omnify_support__"
2762
- };
2763
- }
2764
- function generateOmnifyCommand(options, stubContent) {
2765
- const appPath = options.modelPath.replace(/\/Models$/, "");
2766
- return {
2767
- path: `${appPath}/Console/Commands/OmnifySyncCommand.php`,
2768
- content: stubContent,
2769
- type: "trait",
2770
- // Use trait type for command classes
2771
- overwrite: true,
2772
- // Always overwrite
2773
- schemaName: "__omnify_command__"
2774
- };
2775
- }
2776
2603
  function generateLocalesClass(schema, options, stubContent) {
2777
2604
  const className = toPascalCase(schema.name);
2778
2605
  const localizedDisplayNames = generateLocalizedDisplayNames(schema.displayName);
@@ -2793,8 +2620,6 @@ function generateModels(schemas, options) {
2793
2620
  models.push(generateBaseModel(schemas, resolved, getStubContent("base-model")));
2794
2621
  models.push(generateLocalizedDisplayNameTrait(resolved, getStubContent("has-localized-display-name")));
2795
2622
  models.push(generateServiceProvider(schemas, resolved, getStubContent("service-provider")));
2796
- models.push(generateOmnifySupport(resolved, getStubContent("omnify-support")));
2797
- models.push(generateOmnifyCommand(resolved, getStubContent("omnify-command")));
2798
2623
  for (const schema of Object.values(schemas)) {
2799
2624
  if (schema.kind === "enum" || schema.kind === "partial") {
2800
2625
  continue;
@@ -4591,22 +4416,11 @@ function getResourcePath(resource) {
4591
4416
  }
4592
4417
 
4593
4418
  // src/ai-guides/generator.ts
4594
- import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
4595
- import { resolve, dirname, join } from "path";
4596
- import { fileURLToPath } from "url";
4597
- var __filename = fileURLToPath(import.meta.url);
4598
- var __dirname = dirname(__filename);
4599
- function getStubsDir() {
4600
- const devPath = resolve(__dirname, "../../stubs/ai-guides");
4601
- if (existsSync(devPath)) {
4602
- return devPath;
4603
- }
4604
- const distPath = resolve(__dirname, "../stubs/ai-guides");
4605
- if (existsSync(distPath)) {
4606
- return distPath;
4607
- }
4608
- throw new Error("AI guides stubs not found");
4609
- }
4419
+ import { existsSync, readdirSync } from "fs";
4420
+ import { resolve } from "path";
4421
+ import {
4422
+ generateAIGuides as coreGenerateAIGuides
4423
+ } from "@famgia/omnify-core";
4610
4424
  function extractLaravelBasePath(modelsPath) {
4611
4425
  if (!modelsPath) return "app";
4612
4426
  const normalized = modelsPath.replace(/\\/g, "/");
@@ -4628,50 +4442,17 @@ function extractLaravelRoot(basePath) {
4628
4442
  }
4629
4443
  return "";
4630
4444
  }
4631
- function replacePlaceholders(content, basePath, typescriptPath) {
4632
- const root = extractLaravelRoot(basePath);
4633
- let result = content.replace(/\{\{LARAVEL_BASE\}\}/g, basePath);
4634
- if (root) {
4635
- result = result.replace(/\{\{LARAVEL_ROOT\}\}/g, root + "/");
4636
- } else {
4637
- result = result.replace(/\{\{LARAVEL_ROOT\}\}/g, "");
4638
- }
4639
- const tsPath = typescriptPath || "resources/ts";
4640
- result = result.replace(/\{\{TYPESCRIPT_BASE\}\}/g, tsPath);
4641
- return result;
4642
- }
4643
- function copyStubs(srcDir, destDir, transform) {
4644
- const writtenFiles = [];
4645
- if (!existsSync(srcDir)) {
4646
- return writtenFiles;
4647
- }
4648
- if (!existsSync(destDir)) {
4649
- mkdirSync(destDir, { recursive: true });
4650
- }
4651
- const entries = readdirSync(srcDir, { withFileTypes: true });
4652
- for (const entry of entries) {
4653
- const srcPath = join(srcDir, entry.name);
4654
- if (entry.isDirectory()) {
4655
- const subDestDir = join(destDir, entry.name);
4656
- const subFiles = copyStubs(srcPath, subDestDir, transform);
4657
- writtenFiles.push(...subFiles);
4658
- } else if (entry.isFile() && entry.name.endsWith(".stub")) {
4659
- const destName = entry.name.slice(0, -5);
4660
- const destPath = join(destDir, destName);
4661
- let content = readFileSync(srcPath, "utf-8");
4662
- if (transform) {
4663
- content = transform(content);
4664
- }
4665
- writeFileSync(destPath, content);
4666
- writtenFiles.push(destPath);
4667
- }
4668
- }
4669
- return writtenFiles;
4670
- }
4671
4445
  function generateAIGuides(rootDir, options = {}) {
4672
- const stubsDir = getStubsDir();
4673
4446
  const basePath = options.laravelBasePath || extractLaravelBasePath(options.modelsPath);
4447
+ const laravelRoot = extractLaravelRoot(basePath);
4674
4448
  const tsPath = options.typescriptBasePath || "resources/ts";
4449
+ const coreResult = coreGenerateAIGuides(rootDir, {
4450
+ placeholders: {
4451
+ LARAVEL_BASE: basePath,
4452
+ LARAVEL_ROOT: laravelRoot ? laravelRoot + "/" : "",
4453
+ TYPESCRIPT_BASE: tsPath
4454
+ }
4455
+ });
4675
4456
  const result = {
4676
4457
  claudeGuides: 0,
4677
4458
  claudeRules: 0,
@@ -4680,109 +4461,22 @@ function generateAIGuides(rootDir, options = {}) {
4680
4461
  claudeAgents: 0,
4681
4462
  claudeOmnify: 0,
4682
4463
  cursorRules: 0,
4683
- files: []
4464
+ antigravityRules: 0,
4465
+ files: coreResult.files
4684
4466
  };
4685
- const readmeSrcPath = join(stubsDir, "README.md.stub");
4686
- if (existsSync(readmeSrcPath)) {
4687
- const readmeDestDir = resolve(rootDir, ".claude/omnify");
4688
- if (!existsSync(readmeDestDir)) {
4689
- mkdirSync(readmeDestDir, { recursive: true });
4690
- }
4691
- const content = readFileSync(readmeSrcPath, "utf-8");
4692
- writeFileSync(resolve(readmeDestDir, "README.md"), content);
4693
- result.files.push(resolve(readmeDestDir, "README.md"));
4694
- }
4695
- const claudeSrcDir = join(stubsDir, "laravel");
4696
- const claudeDestDir = resolve(rootDir, ".claude/omnify/guides/laravel");
4697
- if (existsSync(claudeSrcDir)) {
4698
- const files = copyStubs(claudeSrcDir, claudeDestDir);
4699
- result.claudeGuides = files.length;
4700
- result.files.push(...files);
4701
- }
4702
- const reactSrcDir = join(stubsDir, "react");
4703
- const reactDestDir = resolve(rootDir, ".claude/omnify/guides/react");
4704
- if (existsSync(reactSrcDir)) {
4705
- const files = copyStubs(reactSrcDir, reactDestDir);
4706
- result.claudeGuides += files.length;
4707
- result.files.push(...files);
4708
- }
4709
- const claudeRulesSrcDir = join(stubsDir, "claude-rules");
4710
- const claudeRulesDestDir = resolve(rootDir, ".claude/rules/omnify");
4711
- if (existsSync(claudeRulesSrcDir)) {
4712
- const files = copyStubs(
4713
- claudeRulesSrcDir,
4714
- claudeRulesDestDir,
4715
- (content) => replacePlaceholders(content, basePath, tsPath)
4716
- );
4717
- result.claudeRules = files.length;
4718
- result.files.push(...files);
4719
- }
4720
- const claudeChecklistsSrcDir = join(stubsDir, "claude-checklists");
4721
- const claudeChecklistsDestDir = resolve(rootDir, ".claude/omnify/checklists");
4722
- if (existsSync(claudeChecklistsSrcDir)) {
4723
- const files = copyStubs(claudeChecklistsSrcDir, claudeChecklistsDestDir);
4724
- result.claudeChecklists = files.length;
4725
- result.files.push(...files);
4726
- }
4727
- const claudeWorkflowsSrcDir = join(stubsDir, "claude-workflows");
4728
- const claudeWorkflowsDestDir = resolve(rootDir, ".claude/omnify/workflows");
4729
- if (existsSync(claudeWorkflowsSrcDir)) {
4730
- const files = copyStubs(claudeWorkflowsSrcDir, claudeWorkflowsDestDir);
4731
- result.claudeWorkflows = files.length;
4732
- result.files.push(...files);
4733
- }
4734
- const claudeAgentsSrcDir = join(stubsDir, "claude-agents");
4735
- const claudeAgentsDestDir = resolve(rootDir, ".claude/omnify/agents");
4736
- if (existsSync(claudeAgentsSrcDir)) {
4737
- const files = copyStubs(claudeAgentsSrcDir, claudeAgentsDestDir);
4738
- result.claudeAgents = files.length;
4739
- result.files.push(...files);
4740
- }
4741
- const claudeOmnifySrcDir = join(stubsDir, "claude-omnify");
4742
- const claudeOmnifyDestDir = resolve(rootDir, ".claude/omnify/guides/omnify");
4743
- if (existsSync(claudeOmnifySrcDir)) {
4744
- const files = copyStubs(claudeOmnifySrcDir, claudeOmnifyDestDir);
4745
- result.claudeOmnify = files.length;
4746
- result.files.push(...files);
4747
- }
4748
- const cursorSrcDir = join(stubsDir, "cursor");
4749
- const cursorDestDir = resolve(rootDir, ".cursor/rules/omnify");
4750
- if (existsSync(cursorSrcDir)) {
4751
- const files = copyStubs(
4752
- cursorSrcDir,
4753
- cursorDestDir,
4754
- (content) => replacePlaceholders(content, basePath, tsPath)
4755
- );
4756
- result.cursorRules = files.length;
4757
- result.files.push(...files);
4758
- }
4759
- cleanupRootLevelDuplicates(rootDir);
4467
+ const claudeCount = coreResult.counts["claude"] || 0;
4468
+ const cursorCount = coreResult.counts["cursor"] || 0;
4469
+ const antigravityCount = coreResult.counts["antigravity"] || 0;
4470
+ result.claudeGuides = Math.floor(claudeCount * 0.4);
4471
+ result.claudeRules = Math.floor(claudeCount * 0.2);
4472
+ result.claudeChecklists = Math.floor(claudeCount * 0.1);
4473
+ result.claudeWorkflows = Math.floor(claudeCount * 0.1);
4474
+ result.claudeAgents = Math.floor(claudeCount * 0.1);
4475
+ result.claudeOmnify = claudeCount - result.claudeGuides - result.claudeRules - result.claudeChecklists - result.claudeWorkflows - result.claudeAgents;
4476
+ result.cursorRules = cursorCount;
4477
+ result.antigravityRules = antigravityCount;
4760
4478
  return result;
4761
4479
  }
4762
- function cleanupRootLevelDuplicates(rootDir) {
4763
- const claudeOmnify = resolve(rootDir, ".claude/omnify");
4764
- const guidesOmnify = resolve(rootDir, ".claude/omnify/guides/omnify");
4765
- if (!existsSync(guidesOmnify)) return;
4766
- const filesToCleanup = [
4767
- "schema-guide.md",
4768
- "config-guide.md",
4769
- "typescript-guide.md",
4770
- "laravel-guide.md",
4771
- "antdesign-guide.md",
4772
- "react-form-guide.md",
4773
- "japan-guide.md"
4774
- ];
4775
- for (const file of filesToCleanup) {
4776
- const rootFile = resolve(claudeOmnify, file);
4777
- const guidesFile = resolve(guidesOmnify, file);
4778
- if (existsSync(rootFile) && existsSync(guidesFile)) {
4779
- try {
4780
- unlinkSync(rootFile);
4781
- } catch {
4782
- }
4783
- }
4784
- }
4785
- }
4786
4480
  function shouldGenerateAIGuides(rootDir) {
4787
4481
  const claudeDir = resolve(rootDir, ".claude/omnify/guides/laravel");
4788
4482
  const cursorDir = resolve(rootDir, ".cursor/rules/omnify");
@@ -4999,7 +4693,7 @@ function laravelPlugin(options) {
4999
4693
  pluginEnums: ctx.pluginEnums
5000
4694
  };
5001
4695
  const outputs = [];
5002
- const migrationsDir = join2(ctx.cwd, resolved.migrationsPath);
4696
+ const migrationsDir = join(ctx.cwd, resolved.migrationsPath);
5003
4697
  const existingTables = getExistingMigrationTables(migrationsDir);
5004
4698
  if (ctx.changes !== void 0) {
5005
4699
  if (ctx.changes.length === 0) {
@@ -5099,20 +4793,20 @@ function laravelPlugin(options) {
5099
4793
  const laravelRoot = inferLaravelRoot(resolved.providersPath);
5100
4794
  const bootstrapProvidersRelPath = laravelRoot ? `${laravelRoot}/bootstrap/providers.php` : "bootstrap/providers.php";
5101
4795
  const configAppRelPath = laravelRoot ? `${laravelRoot}/config/app.php` : "config/app.php";
5102
- const bootstrapProvidersPath = join2(ctx.cwd, bootstrapProvidersRelPath);
5103
- const configAppPath = join2(ctx.cwd, configAppRelPath);
4796
+ const bootstrapProvidersPath = join(ctx.cwd, bootstrapProvidersRelPath);
4797
+ const configAppPath = join(ctx.cwd, configAppRelPath);
5104
4798
  let existingContent = null;
5105
4799
  let laravelVersion;
5106
4800
  if (existsSync2(bootstrapProvidersPath)) {
5107
4801
  laravelVersion = "laravel11+";
5108
4802
  try {
5109
- existingContent = readFileSync2(bootstrapProvidersPath, "utf-8");
4803
+ existingContent = readFileSync(bootstrapProvidersPath, "utf-8");
5110
4804
  } catch {
5111
4805
  existingContent = null;
5112
4806
  }
5113
4807
  } else if (existsSync2(configAppPath)) {
5114
4808
  try {
5115
- const configContent = readFileSync2(configAppPath, "utf-8");
4809
+ const configContent = readFileSync(configAppPath, "utf-8");
5116
4810
  if (/'providers'\s*=>\s*\[/.test(configContent)) {
5117
4811
  laravelVersion = "laravel10-";
5118
4812
  existingContent = configContent;
@@ -5240,7 +4934,9 @@ function laravelPlugin(options) {
5240
4934
  laravelBasePath: "app"
5241
4935
  });
5242
4936
  const claudeTotal = result.claudeGuides + result.claudeRules + result.claudeChecklists + result.claudeWorkflows + result.claudeAgents + result.claudeOmnify;
5243
- ctx.logger.info(`Generated ${claudeTotal} Claude files, ${result.cursorRules} Cursor rules`);
4937
+ const antigravityTotal = result.antigravityRules || 0;
4938
+ const antigravityInfo = antigravityTotal > 0 ? `, ${antigravityTotal} Antigravity rules` : "";
4939
+ ctx.logger.info(`Generated ${claudeTotal} Claude files, ${result.cursorRules} Cursor rules${antigravityInfo}`);
5244
4940
  return [];
5245
4941
  }
5246
4942
  };
@@ -5300,4 +4996,4 @@ export {
5300
4996
  shouldGenerateAIGuides,
5301
4997
  laravelPlugin
5302
4998
  };
5303
- //# sourceMappingURL=chunk-F23JGVX6.js.map
4999
+ //# sourceMappingURL=chunk-MQGFUYP7.js.map