@famgia/omnify-laravel 0.0.82 → 0.0.84

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.cjs CHANGED
@@ -2215,12 +2215,14 @@ function generateModels(schemas, options) {
2215
2215
  function getModelPath(model) {
2216
2216
  return model.path;
2217
2217
  }
2218
- function generateProviderRegistration(existingContent, laravelVersion) {
2218
+ function generateProviderRegistration(existingContent, laravelVersion, laravelRoot = "") {
2219
2219
  const providerClass = "App\\Providers\\OmnifyServiceProvider::class";
2220
2220
  const providerLine = ` ${providerClass},`;
2221
+ const bootstrapPath = laravelRoot ? `${laravelRoot}/bootstrap/providers.php` : "bootstrap/providers.php";
2222
+ const configPath = laravelRoot ? `${laravelRoot}/config/app.php` : "config/app.php";
2221
2223
  if (existingContent && existingContent.includes("OmnifyServiceProvider")) {
2222
2224
  return {
2223
- path: laravelVersion === "laravel11+" ? "bootstrap/providers.php" : "config/app.php",
2225
+ path: laravelVersion === "laravel11+" ? bootstrapPath : configPath,
2224
2226
  content: existingContent,
2225
2227
  laravelVersion,
2226
2228
  alreadyRegistered: true
@@ -2240,14 +2242,14 @@ function generateProviderRegistration(existingContent, laravelVersion) {
2240
2242
  result.push(line);
2241
2243
  }
2242
2244
  return {
2243
- path: "bootstrap/providers.php",
2245
+ path: bootstrapPath,
2244
2246
  content: result.join("\n"),
2245
2247
  laravelVersion,
2246
2248
  alreadyRegistered: false
2247
2249
  };
2248
2250
  } else {
2249
2251
  return {
2250
- path: "bootstrap/providers.php",
2252
+ path: bootstrapPath,
2251
2253
  content: `<?php
2252
2254
 
2253
2255
  return [
@@ -2289,7 +2291,7 @@ ${providerLine}
2289
2291
  const lastNewline = beforeClose.lastIndexOf("\n");
2290
2292
  const content = existingContent.substring(0, lastNewline + 1) + providerLine + "\n" + existingContent.substring(lastNewline + 1);
2291
2293
  return {
2292
- path: "config/app.php",
2294
+ path: configPath,
2293
2295
  content,
2294
2296
  laravelVersion,
2295
2297
  alreadyRegistered: false
@@ -3594,6 +3596,18 @@ function getResourcePath(resource) {
3594
3596
  }
3595
3597
 
3596
3598
  // src/plugin.ts
3599
+ function inferLaravelRoot(providersPath) {
3600
+ const normalized = providersPath.replace(/\\/g, "/");
3601
+ const match = normalized.match(/^(.*)\/app\/Providers\/?$/i);
3602
+ if (match && match[1]) {
3603
+ return match[1];
3604
+ }
3605
+ const baseMatch = normalized.match(/^(.*)\/app\/Providers\/OmnifyBase\/?$/i);
3606
+ if (baseMatch && baseMatch[1]) {
3607
+ return baseMatch[1];
3608
+ }
3609
+ return "";
3610
+ }
3597
3611
  function getExistingMigrationTables(migrationsDir) {
3598
3612
  const existingTables = /* @__PURE__ */ new Set();
3599
3613
  if (!(0, import_node_fs.existsSync)(migrationsDir)) {
@@ -3863,8 +3877,11 @@ function laravelPlugin(options) {
3863
3877
  schemaName: model.schemaName
3864
3878
  }
3865
3879
  }));
3866
- const bootstrapProvidersPath = (0, import_node_path.join)(ctx.cwd, "bootstrap/providers.php");
3867
- const configAppPath = (0, import_node_path.join)(ctx.cwd, "config/app.php");
3880
+ const laravelRoot = inferLaravelRoot(resolved.providersPath);
3881
+ const bootstrapProvidersRelPath = laravelRoot ? `${laravelRoot}/bootstrap/providers.php` : "bootstrap/providers.php";
3882
+ const configAppRelPath = laravelRoot ? `${laravelRoot}/config/app.php` : "config/app.php";
3883
+ const bootstrapProvidersPath = (0, import_node_path.join)(ctx.cwd, bootstrapProvidersRelPath);
3884
+ const configAppPath = (0, import_node_path.join)(ctx.cwd, configAppRelPath);
3868
3885
  let existingContent = null;
3869
3886
  let laravelVersion;
3870
3887
  if ((0, import_node_fs.existsSync)(bootstrapProvidersPath)) {
@@ -3875,16 +3892,24 @@ function laravelPlugin(options) {
3875
3892
  existingContent = null;
3876
3893
  }
3877
3894
  } else if ((0, import_node_fs.existsSync)(configAppPath)) {
3878
- laravelVersion = "laravel10-";
3879
3895
  try {
3880
- existingContent = (0, import_node_fs.readFileSync)(configAppPath, "utf-8");
3896
+ const configContent = (0, import_node_fs.readFileSync)(configAppPath, "utf-8");
3897
+ if (/'providers'\s*=>\s*\[/.test(configContent)) {
3898
+ laravelVersion = "laravel10-";
3899
+ existingContent = configContent;
3900
+ } else {
3901
+ laravelVersion = "laravel11+";
3902
+ existingContent = null;
3903
+ }
3881
3904
  } catch {
3905
+ laravelVersion = "laravel11+";
3882
3906
  existingContent = null;
3883
3907
  }
3884
3908
  } else {
3885
3909
  laravelVersion = "laravel11+";
3910
+ existingContent = null;
3886
3911
  }
3887
- const registration = generateProviderRegistration(existingContent, laravelVersion);
3912
+ const registration = generateProviderRegistration(existingContent, laravelVersion, laravelRoot);
3888
3913
  if (registration && !registration.alreadyRegistered) {
3889
3914
  outputs.push({
3890
3915
  path: registration.path,