@famgia/omnify-laravel 2.0.13 → 2.0.15

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, readdirSync } from "fs";
3
+ import { join } from "path";
4
4
 
5
5
  // src/migration/schema-builder.ts
6
6
  import { resolveLocalizedString } from "@famgia/omnify-types";
@@ -4701,173 +4701,17 @@ function getResourcePath(resource) {
4701
4701
  return resource.path;
4702
4702
  }
4703
4703
 
4704
- // src/ai-guides/generator.ts
4705
- import { existsSync, readdirSync, readFileSync, writeFileSync } from "fs";
4706
- import { resolve, join } from "path";
4707
- import {
4708
- generateAIGuides as coreGenerateAIGuides
4709
- } from "@famgia/omnify-core";
4710
- function extractLaravelBasePath(modelsPath) {
4711
- if (!modelsPath) return "app";
4712
- const normalized = modelsPath.replace(/\\/g, "/");
4713
- const match = normalized.match(/^(.+?)\/Models(?:\/.*)?$/);
4714
- if (match && match[1]) {
4715
- return match[1];
4716
- }
4717
- const parts = normalized.split("/").filter(Boolean);
4718
- if (parts.length > 1) {
4719
- return parts.slice(0, -1).join("/");
4720
- }
4721
- return "app";
4722
- }
4723
- function extractLaravelRoot(basePath) {
4724
- const normalized = basePath.replace(/\\/g, "/");
4725
- const match = normalized.match(/^(.+?)\/app$/);
4726
- if (match && match[1]) {
4727
- return match[1];
4728
- }
4729
- return "";
4730
- }
4731
- function expandPackageGlobs(cursorRulesDir, basePath, packagePaths) {
4732
- if (!packagePaths.length || !existsSync(cursorRulesDir)) {
4733
- return;
4734
- }
4735
- const files = readdirSync(cursorRulesDir).filter((f) => f.endsWith(".mdc"));
4736
- for (const file of files) {
4737
- const filePath = join(cursorRulesDir, file);
4738
- let content = readFileSync(filePath, "utf-8");
4739
- if (!content.startsWith("---")) continue;
4740
- const endIndex = content.indexOf("---", 3);
4741
- if (endIndex === -1) continue;
4742
- const frontmatter = content.substring(0, endIndex + 3);
4743
- const body = content.substring(endIndex + 3);
4744
- const globsMatch = frontmatter.match(/globs:\s*\[([^\]]*)\]/);
4745
- if (!globsMatch) continue;
4746
- const originalGlobs = globsMatch[1].split(",").map((g) => g.trim().replace(/["']/g, "")).filter(Boolean);
4747
- const specificPatterns = [
4748
- { pattern: `${basePath}/Models/OmnifyBase/`, suffix: "Models/OmnifyBase/" },
4749
- { pattern: `${basePath}/Models/`, suffix: "Models/" }
4750
- ];
4751
- const generalAppPattern = `${basePath}/**/*.php`;
4752
- const newGlobs = [];
4753
- for (const glob of originalGlobs) {
4754
- newGlobs.push(glob);
4755
- if (glob === generalAppPattern) {
4756
- for (const pkg of packagePaths) {
4757
- const pkgBase = pkg.base.replace(/^\.\//, "");
4758
- const pkgGlob = `${pkgBase}/src/**/*.php`;
4759
- if (!newGlobs.includes(pkgGlob)) {
4760
- newGlobs.push(pkgGlob);
4761
- }
4762
- }
4763
- continue;
4764
- }
4765
- for (const { pattern, suffix } of specificPatterns) {
4766
- if (glob.includes(pattern)) {
4767
- for (const pkg of packagePaths) {
4768
- const pkgBase = pkg.base.replace(/^\.\//, "");
4769
- const pkgModelsPath = pkg.modelsPath ?? "src/Models";
4770
- const afterModels = glob.split(pattern)[1] || "";
4771
- const modelsSuffix = suffix.replace("Models/", "");
4772
- const pkgGlob = `${pkgBase}/${pkgModelsPath}/${modelsSuffix}${afterModels}`;
4773
- if (!newGlobs.includes(pkgGlob)) {
4774
- newGlobs.push(pkgGlob);
4775
- }
4776
- }
4777
- break;
4778
- }
4779
- }
4780
- }
4781
- if (newGlobs.length > originalGlobs.length) {
4782
- const newGlobsStr = newGlobs.map((g) => `"${g}"`).join(", ");
4783
- const newFrontmatter = frontmatter.replace(
4784
- /globs:\s*\[[^\]]*\]/,
4785
- `globs: [${newGlobsStr}]`
4786
- );
4787
- writeFileSync(filePath, newFrontmatter + body);
4788
- }
4789
- }
4790
- }
4791
- function generateAIGuides(rootDir, options = {}) {
4792
- const basePath = options.laravelBasePath || extractLaravelBasePath(options.modelsPath);
4793
- const laravelRoot = extractLaravelRoot(basePath);
4794
- const tsPath = options.typescriptBasePath || "resources/ts";
4795
- const coreResult = coreGenerateAIGuides(rootDir, {
4796
- placeholders: {
4797
- LARAVEL_BASE: basePath,
4798
- LARAVEL_ROOT: laravelRoot ? laravelRoot + "/" : "",
4799
- TYPESCRIPT_BASE: tsPath
4800
- }
4801
- });
4802
- if (options.packagePaths?.length) {
4803
- const cursorRulesDir = resolve(rootDir, ".cursor/rules/omnify");
4804
- expandPackageGlobs(cursorRulesDir, basePath, options.packagePaths);
4805
- }
4806
- const result = {
4807
- claudeGuides: 0,
4808
- claudeRules: 0,
4809
- claudeChecklists: 0,
4810
- claudeWorkflows: 0,
4811
- claudeAgents: 0,
4812
- claudeOmnify: 0,
4813
- cursorRules: 0,
4814
- antigravityRules: 0,
4815
- files: coreResult.files
4816
- };
4817
- const claudeCount = coreResult.counts["claude"] || 0;
4818
- const cursorCount = coreResult.counts["cursor"] || 0;
4819
- const antigravityCount = coreResult.counts["antigravity"] || 0;
4820
- result.claudeGuides = Math.floor(claudeCount * 0.4);
4821
- result.claudeRules = Math.floor(claudeCount * 0.2);
4822
- result.claudeChecklists = Math.floor(claudeCount * 0.1);
4823
- result.claudeWorkflows = Math.floor(claudeCount * 0.1);
4824
- result.claudeAgents = Math.floor(claudeCount * 0.1);
4825
- result.claudeOmnify = claudeCount - result.claudeGuides - result.claudeRules - result.claudeChecklists - result.claudeWorkflows - result.claudeAgents;
4826
- result.cursorRules = cursorCount;
4827
- result.antigravityRules = antigravityCount;
4828
- return result;
4829
- }
4830
- function shouldGenerateAIGuides(rootDir) {
4831
- const claudeDir = resolve(rootDir, ".claude/omnify/guides/laravel");
4832
- const cursorDir = resolve(rootDir, ".cursor/rules/omnify");
4833
- if (!existsSync(claudeDir) || !existsSync(cursorDir)) {
4834
- return true;
4835
- }
4836
- try {
4837
- const claudeFiles = readdirSync(claudeDir);
4838
- const cursorFiles = readdirSync(cursorDir);
4839
- const hasLaravelRules = cursorFiles.some((f) => f.startsWith("laravel"));
4840
- return claudeFiles.length === 0 || !hasLaravelRules;
4841
- } catch {
4842
- return true;
4843
- }
4844
- }
4845
-
4846
4704
  // src/plugin.ts
4847
4705
  function getPluginVersion() {
4848
4706
  try {
4849
4707
  const pkgPath = new URL("../package.json", import.meta.url);
4850
- const pkgContent = readFileSync2(pkgPath, "utf-8");
4708
+ const pkgContent = readFileSync(pkgPath, "utf-8");
4851
4709
  const pkg = JSON.parse(pkgContent);
4852
4710
  return pkg.version;
4853
4711
  } catch {
4854
4712
  return "unknown";
4855
4713
  }
4856
4714
  }
4857
- function extractPackagePaths(schemas) {
4858
- const packageMap = /* @__PURE__ */ new Map();
4859
- for (const schema of Object.values(schemas)) {
4860
- const pkg = schema.packageOutput?.laravel;
4861
- if (pkg?.base && !packageMap.has(pkg.base)) {
4862
- packageMap.set(pkg.base, {
4863
- base: pkg.base,
4864
- modelsPath: pkg.modelsPath ?? "src/Models",
4865
- migrationsPath: pkg.migrationsPath ?? "database/migrations"
4866
- });
4867
- }
4868
- }
4869
- return Array.from(packageMap.values());
4870
- }
4871
4715
  function getMigrationPathForSchema(migration, schemas, defaultPath) {
4872
4716
  if (migration.schemaName) {
4873
4717
  const schema = schemas[migration.schemaName];
@@ -4893,11 +4737,11 @@ function inferLaravelRoot(providersPath) {
4893
4737
  }
4894
4738
  function getExistingMigrationTables(migrationsDir) {
4895
4739
  const existingTables = /* @__PURE__ */ new Set();
4896
- if (!existsSync2(migrationsDir)) {
4740
+ if (!existsSync(migrationsDir)) {
4897
4741
  return existingTables;
4898
4742
  }
4899
4743
  try {
4900
- const files = readdirSync2(migrationsDir);
4744
+ const files = readdirSync(migrationsDir);
4901
4745
  const createMigrationPattern = /^\d{4}_\d{2}_\d{2}_\d{6}_create_(.+)_table\.php$/;
4902
4746
  for (const file of files) {
4903
4747
  const match = file.match(createMigrationPattern);
@@ -4913,21 +4757,21 @@ function getMigrationsDirForSchema(schema, cwd, defaultMigrationsPath) {
4913
4757
  if (schema?.packageOutput?.laravel) {
4914
4758
  const pkg = schema.packageOutput.laravel;
4915
4759
  const migrationsPath = pkg.migrationsPath ?? "database/migrations";
4916
- return join2(cwd, pkg.base, migrationsPath);
4760
+ return join(cwd, pkg.base, migrationsPath);
4917
4761
  }
4918
- return join2(cwd, defaultMigrationsPath);
4762
+ return join(cwd, defaultMigrationsPath);
4919
4763
  }
4920
4764
  function buildExistingTablesMap(schemas, cwd, defaultMigrationsPath) {
4921
4765
  const tablesMap = /* @__PURE__ */ new Map();
4922
4766
  const checkedDirs = /* @__PURE__ */ new Set();
4923
- const defaultDir = join2(cwd, defaultMigrationsPath);
4767
+ const defaultDir = join(cwd, defaultMigrationsPath);
4924
4768
  tablesMap.set(defaultDir, getExistingMigrationTables(defaultDir));
4925
4769
  checkedDirs.add(defaultDir);
4926
4770
  for (const schema of Object.values(schemas)) {
4927
4771
  if (schema.packageOutput?.laravel) {
4928
4772
  const pkg = schema.packageOutput.laravel;
4929
4773
  const migrationsPath = pkg.migrationsPath ?? "database/migrations";
4930
- const pkgDir = join2(cwd, pkg.base, migrationsPath);
4774
+ const pkgDir = join(cwd, pkg.base, migrationsPath);
4931
4775
  if (!checkedDirs.has(pkgDir)) {
4932
4776
  tablesMap.set(pkgDir, getExistingMigrationTables(pkgDir));
4933
4777
  checkedDirs.add(pkgDir);
@@ -5222,20 +5066,20 @@ function laravelPlugin(options) {
5222
5066
  const laravelRoot = inferLaravelRoot(resolved.providersPath);
5223
5067
  const bootstrapProvidersRelPath = laravelRoot ? `${laravelRoot}/bootstrap/providers.php` : "bootstrap/providers.php";
5224
5068
  const configAppRelPath = laravelRoot ? `${laravelRoot}/config/app.php` : "config/app.php";
5225
- const bootstrapProvidersPath = join2(ctx.cwd, bootstrapProvidersRelPath);
5226
- const configAppPath = join2(ctx.cwd, configAppRelPath);
5069
+ const bootstrapProvidersPath = join(ctx.cwd, bootstrapProvidersRelPath);
5070
+ const configAppPath = join(ctx.cwd, configAppRelPath);
5227
5071
  let existingContent = null;
5228
5072
  let laravelVersion;
5229
- if (existsSync2(bootstrapProvidersPath)) {
5073
+ if (existsSync(bootstrapProvidersPath)) {
5230
5074
  laravelVersion = "laravel11+";
5231
5075
  try {
5232
- existingContent = readFileSync2(bootstrapProvidersPath, "utf-8");
5076
+ existingContent = readFileSync(bootstrapProvidersPath, "utf-8");
5233
5077
  } catch {
5234
5078
  existingContent = null;
5235
5079
  }
5236
- } else if (existsSync2(configAppPath)) {
5080
+ } else if (existsSync(configAppPath)) {
5237
5081
  try {
5238
- const configContent = readFileSync2(configAppPath, "utf-8");
5082
+ const configContent = readFileSync(configAppPath, "utf-8");
5239
5083
  if (/'providers'\s*=>\s*\[/.test(configContent)) {
5240
5084
  laravelVersion = "laravel10-";
5241
5085
  existingContent = configContent;
@@ -5349,24 +5193,6 @@ function laravelPlugin(options) {
5349
5193
  }));
5350
5194
  }
5351
5195
  };
5352
- const aiGuidesGenerator = {
5353
- name: "laravel-ai-guides",
5354
- description: "Generate AI assistant guides (Claude, Cursor) for Laravel development",
5355
- generate: async (ctx) => {
5356
- const packagePaths = extractPackagePaths(ctx.schemas);
5357
- const result = generateAIGuides(ctx.cwd, {
5358
- modelsPath: resolved.modelsPath,
5359
- migrationsPath: resolved.migrationsPath,
5360
- laravelBasePath: "app",
5361
- packagePaths
5362
- });
5363
- const claudeTotal = result.claudeGuides + result.claudeRules + result.claudeChecklists + result.claudeWorkflows + result.claudeAgents + result.claudeOmnify;
5364
- const antigravityTotal = result.antigravityRules || 0;
5365
- const antigravityInfo = antigravityTotal > 0 ? `, ${antigravityTotal} Antigravity rules` : "";
5366
- ctx.logger.info(`Generated ${claudeTotal} Claude files, ${result.cursorRules} Cursor rules${antigravityInfo}`);
5367
- return [];
5368
- }
5369
- };
5370
5196
  const generators = [migrationGenerator];
5371
5197
  if (resolved.generateModels) {
5372
5198
  generators.push(modelGenerator);
@@ -5380,7 +5206,6 @@ function laravelPlugin(options) {
5380
5206
  if (resolved.generateResources) {
5381
5207
  generators.push(resourceGenerator);
5382
5208
  }
5383
- generators.push(aiGuidesGenerator);
5384
5209
  return {
5385
5210
  name: "@famgia/omnify-laravel",
5386
5211
  version: getPluginVersion(),
@@ -5419,8 +5244,6 @@ export {
5419
5244
  generateProviderRegistration,
5420
5245
  generateFactories,
5421
5246
  getFactoryPath,
5422
- generateAIGuides,
5423
- shouldGenerateAIGuides,
5424
5247
  laravelPlugin
5425
5248
  };
5426
- //# sourceMappingURL=chunk-ILDRIQLW.js.map
5249
+ //# sourceMappingURL=chunk-3RGYQPB2.js.map