@famgia/omnify-laravel 0.0.122 → 0.0.124
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/{chunk-NMX3TLZT.js → chunk-C3AGVZB4.js} +176 -1
- package/dist/chunk-C3AGVZB4.js.map +1 -0
- package/dist/index.cjs +175 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +175 -0
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +4 -4
- package/stubs/Omnify.php.stub +94 -0
- package/stubs/commands/OmnifySyncCommand.php.stub +65 -0
- package/dist/chunk-NMX3TLZT.js.map +0 -1
|
@@ -2172,6 +2172,7 @@ class {{CLASS_NAME}} extends {{CLASS_NAME}}BaseModel
|
|
|
2172
2172
|
|
|
2173
2173
|
namespace App\\Providers;
|
|
2174
2174
|
|
|
2175
|
+
use App\\Support\\Omnify;
|
|
2175
2176
|
use Illuminate\\Database\\Eloquent\\Relations\\Relation;
|
|
2176
2177
|
use Illuminate\\Support\\ServiceProvider;
|
|
2177
2178
|
|
|
@@ -2183,6 +2184,7 @@ use Illuminate\\Support\\ServiceProvider;
|
|
|
2183
2184
|
*
|
|
2184
2185
|
* - Loads Omnify migrations from database/migrations/omnify
|
|
2185
2186
|
* - Registers morph map for polymorphic relationships
|
|
2187
|
+
* - Exports schema paths for CLI consumption
|
|
2186
2188
|
*
|
|
2187
2189
|
* @generated by @famgia/omnify-laravel
|
|
2188
2190
|
*/
|
|
@@ -2208,6 +2210,11 @@ class OmnifyServiceProvider extends ServiceProvider
|
|
|
2208
2210
|
Relation::enforceMorphMap([
|
|
2209
2211
|
{{MORPH_MAP}}
|
|
2210
2212
|
]);
|
|
2213
|
+
|
|
2214
|
+
// Export registered schema paths for CLI (only when running artisan commands)
|
|
2215
|
+
if ($this->app->runningInConsole()) {
|
|
2216
|
+
Omnify::exportPaths();
|
|
2217
|
+
}
|
|
2211
2218
|
}
|
|
2212
2219
|
}
|
|
2213
2220
|
`,
|
|
@@ -2336,6 +2343,148 @@ class {{CLASS_NAME}}Locales
|
|
|
2336
2343
|
{{LOCALIZED_PROPERTY_DISPLAY_NAMES}}
|
|
2337
2344
|
];
|
|
2338
2345
|
}
|
|
2346
|
+
`,
|
|
2347
|
+
"omnify-support": `<?php
|
|
2348
|
+
|
|
2349
|
+
namespace App\\Support;
|
|
2350
|
+
|
|
2351
|
+
/**
|
|
2352
|
+
* Omnify Support Class
|
|
2353
|
+
*
|
|
2354
|
+
* Allows Laravel packages to register their schema directories.
|
|
2355
|
+
*
|
|
2356
|
+
* DO NOT EDIT - This file is auto-generated by Omnify.
|
|
2357
|
+
* Any changes will be overwritten on next generation.
|
|
2358
|
+
*
|
|
2359
|
+
* @example
|
|
2360
|
+
* // In your package's ServiceProvider:
|
|
2361
|
+
* use App\\Support\\Omnify;
|
|
2362
|
+
*
|
|
2363
|
+
* public function boot()
|
|
2364
|
+
* {
|
|
2365
|
+
* Omnify::addSchemaPath(__DIR__.'/../database/schemas');
|
|
2366
|
+
* }
|
|
2367
|
+
*
|
|
2368
|
+
* @generated by @famgia/omnify-laravel
|
|
2369
|
+
*/
|
|
2370
|
+
class Omnify
|
|
2371
|
+
{
|
|
2372
|
+
/**
|
|
2373
|
+
* Registered schema paths from packages.
|
|
2374
|
+
*
|
|
2375
|
+
* @var array<array{path: string, namespace: string|null}>
|
|
2376
|
+
*/
|
|
2377
|
+
protected static array $schemaPaths = [];
|
|
2378
|
+
|
|
2379
|
+
/**
|
|
2380
|
+
* Register a schema directory path.
|
|
2381
|
+
*
|
|
2382
|
+
* @param string $path Absolute path to schema directory
|
|
2383
|
+
* @param string|null $namespace Optional namespace prefix for schemas
|
|
2384
|
+
* @return void
|
|
2385
|
+
*/
|
|
2386
|
+
public static function addSchemaPath(string $path, ?string $namespace = null): void
|
|
2387
|
+
{
|
|
2388
|
+
$realPath = realpath($path);
|
|
2389
|
+
|
|
2390
|
+
if ($realPath === false) {
|
|
2391
|
+
$realPath = $path;
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
static::$schemaPaths[] = [
|
|
2395
|
+
'path' => $realPath,
|
|
2396
|
+
'namespace' => $namespace,
|
|
2397
|
+
];
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
/**
|
|
2401
|
+
* Get all registered schema paths.
|
|
2402
|
+
*
|
|
2403
|
+
* @return array<array{path: string, namespace: string|null}>
|
|
2404
|
+
*/
|
|
2405
|
+
public static function getSchemaPaths(): array
|
|
2406
|
+
{
|
|
2407
|
+
return static::$schemaPaths;
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* Clear all registered schema paths.
|
|
2412
|
+
*/
|
|
2413
|
+
public static function clearSchemaPaths(): void
|
|
2414
|
+
{
|
|
2415
|
+
static::$schemaPaths = [];
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
/**
|
|
2419
|
+
* Export schema paths to JSON file for CLI consumption.
|
|
2420
|
+
*
|
|
2421
|
+
* @param string|null $outputPath Path to write JSON file
|
|
2422
|
+
* @return string Path to the generated file
|
|
2423
|
+
*/
|
|
2424
|
+
public static function exportPaths(?string $outputPath = null): string
|
|
2425
|
+
{
|
|
2426
|
+
$outputPath = $outputPath ?? storage_path('omnify/schema-paths.json');
|
|
2427
|
+
|
|
2428
|
+
$dir = dirname($outputPath);
|
|
2429
|
+
if (!is_dir($dir)) {
|
|
2430
|
+
mkdir($dir, 0755, true);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
$data = [
|
|
2434
|
+
'generated_at' => date('c'),
|
|
2435
|
+
'paths' => static::$schemaPaths,
|
|
2436
|
+
];
|
|
2437
|
+
|
|
2438
|
+
file_put_contents($outputPath, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
|
2439
|
+
|
|
2440
|
+
return $outputPath;
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
`,
|
|
2444
|
+
"omnify-command": `<?php
|
|
2445
|
+
|
|
2446
|
+
namespace App\\Console\\Commands;
|
|
2447
|
+
|
|
2448
|
+
use App\\Support\\Omnify;
|
|
2449
|
+
use Illuminate\\Console\\Command;
|
|
2450
|
+
|
|
2451
|
+
/**
|
|
2452
|
+
* Sync registered schema paths for Omnify CLI.
|
|
2453
|
+
*
|
|
2454
|
+
* DO NOT EDIT - This file is auto-generated by Omnify.
|
|
2455
|
+
* Any changes will be overwritten on next generation.
|
|
2456
|
+
*
|
|
2457
|
+
* @generated by @famgia/omnify-laravel
|
|
2458
|
+
*/
|
|
2459
|
+
class OmnifySyncCommand extends Command
|
|
2460
|
+
{
|
|
2461
|
+
protected $signature = 'omnify:sync {--output= : Custom output path}';
|
|
2462
|
+
|
|
2463
|
+
protected $description = 'Export registered schema paths for Omnify CLI';
|
|
2464
|
+
|
|
2465
|
+
public function handle(): int
|
|
2466
|
+
{
|
|
2467
|
+
$this->info('Syncing Omnify schema paths...');
|
|
2468
|
+
|
|
2469
|
+
$paths = Omnify::getSchemaPaths();
|
|
2470
|
+
|
|
2471
|
+
if (empty($paths)) {
|
|
2472
|
+
$this->warn('No additional schema paths registered.');
|
|
2473
|
+
$this->line('Tip: Packages can use Omnify::addSchemaPath()');
|
|
2474
|
+
} else {
|
|
2475
|
+
$this->line('Found ' . count($paths) . ' path(s):');
|
|
2476
|
+
foreach ($paths as $entry) {
|
|
2477
|
+
$ns = $entry['namespace'] ? " [{$entry['namespace']}]" : '';
|
|
2478
|
+
$this->line(" \u2022 {$entry['path']}{$ns}");
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
$filePath = Omnify::exportPaths($this->option('output'));
|
|
2483
|
+
$this->info("\u2713 Exported to: {$filePath}");
|
|
2484
|
+
|
|
2485
|
+
return Command::SUCCESS;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2339
2488
|
`
|
|
2340
2489
|
};
|
|
2341
2490
|
return stubs[stubName] ?? "";
|
|
@@ -2366,6 +2515,30 @@ function generateLocalizedDisplayNameTrait(options, stubContent) {
|
|
|
2366
2515
|
schemaName: "__trait__"
|
|
2367
2516
|
};
|
|
2368
2517
|
}
|
|
2518
|
+
function generateOmnifySupport(options, stubContent) {
|
|
2519
|
+
const appPath = options.modelPath.replace(/\/Models$/, "");
|
|
2520
|
+
return {
|
|
2521
|
+
path: `${appPath}/Support/Omnify.php`,
|
|
2522
|
+
content: stubContent,
|
|
2523
|
+
type: "trait",
|
|
2524
|
+
// Use trait type for support classes
|
|
2525
|
+
overwrite: true,
|
|
2526
|
+
// Always overwrite
|
|
2527
|
+
schemaName: "__omnify_support__"
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
function generateOmnifyCommand(options, stubContent) {
|
|
2531
|
+
const appPath = options.modelPath.replace(/\/Models$/, "");
|
|
2532
|
+
return {
|
|
2533
|
+
path: `${appPath}/Console/Commands/OmnifySyncCommand.php`,
|
|
2534
|
+
content: stubContent,
|
|
2535
|
+
type: "trait",
|
|
2536
|
+
// Use trait type for command classes
|
|
2537
|
+
overwrite: true,
|
|
2538
|
+
// Always overwrite
|
|
2539
|
+
schemaName: "__omnify_command__"
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2369
2542
|
function generateLocalesClass(schema, options, stubContent) {
|
|
2370
2543
|
const className = toPascalCase(schema.name);
|
|
2371
2544
|
const localizedDisplayNames = generateLocalizedDisplayNames(schema.displayName);
|
|
@@ -2386,6 +2559,8 @@ function generateModels(schemas, options) {
|
|
|
2386
2559
|
models.push(generateBaseModel(schemas, resolved, getStubContent("base-model")));
|
|
2387
2560
|
models.push(generateLocalizedDisplayNameTrait(resolved, getStubContent("has-localized-display-name")));
|
|
2388
2561
|
models.push(generateServiceProvider(schemas, resolved, getStubContent("service-provider")));
|
|
2562
|
+
models.push(generateOmnifySupport(resolved, getStubContent("omnify-support")));
|
|
2563
|
+
models.push(generateOmnifyCommand(resolved, getStubContent("omnify-command")));
|
|
2389
2564
|
for (const schema of Object.values(schemas)) {
|
|
2390
2565
|
if (schema.kind === "enum") {
|
|
2391
2566
|
continue;
|
|
@@ -4868,4 +5043,4 @@ export {
|
|
|
4868
5043
|
shouldGenerateAIGuides,
|
|
4869
5044
|
laravelPlugin
|
|
4870
5045
|
};
|
|
4871
|
-
//# sourceMappingURL=chunk-
|
|
5046
|
+
//# sourceMappingURL=chunk-C3AGVZB4.js.map
|