@famgia/omnify-laravel 0.0.122 → 0.0.123
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
package/dist/plugin.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@famgia/omnify-laravel",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.123",
|
|
4
4
|
"description": "Laravel migration and TypeScript type generator for omnify-schema",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@famgia/omnify-types": "0.0.
|
|
29
|
-
"@famgia/omnify-
|
|
30
|
-
"@famgia/omnify-
|
|
28
|
+
"@famgia/omnify-types": "0.0.112",
|
|
29
|
+
"@famgia/omnify-core": "0.0.114",
|
|
30
|
+
"@famgia/omnify-atlas": "0.0.108"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsup",
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace App\Support;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Omnify Support Class
|
|
7
|
+
*
|
|
8
|
+
* Allows Laravel packages to register their schema directories.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // In your package's ServiceProvider:
|
|
12
|
+
* use App\Support\Omnify;
|
|
13
|
+
*
|
|
14
|
+
* public function boot()
|
|
15
|
+
* {
|
|
16
|
+
* Omnify::addSchemaPath(__DIR__.'/../database/schemas');
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
class Omnify
|
|
20
|
+
{
|
|
21
|
+
/**
|
|
22
|
+
* Registered schema paths from packages.
|
|
23
|
+
*
|
|
24
|
+
* @var array<string>
|
|
25
|
+
*/
|
|
26
|
+
protected static array $schemaPaths = [];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Register a schema directory path.
|
|
30
|
+
*
|
|
31
|
+
* @param string $path Absolute path to schema directory
|
|
32
|
+
* @param string|null $namespace Optional namespace prefix for schemas
|
|
33
|
+
* @return void
|
|
34
|
+
*/
|
|
35
|
+
public static function addSchemaPath(string $path, ?string $namespace = null): void
|
|
36
|
+
{
|
|
37
|
+
$realPath = realpath($path);
|
|
38
|
+
|
|
39
|
+
if ($realPath === false) {
|
|
40
|
+
// Path doesn't exist yet, store as-is
|
|
41
|
+
$realPath = $path;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static::$schemaPaths[] = [
|
|
45
|
+
'path' => $realPath,
|
|
46
|
+
'namespace' => $namespace,
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get all registered schema paths.
|
|
52
|
+
*
|
|
53
|
+
* @return array<array{path: string, namespace: string|null}>
|
|
54
|
+
*/
|
|
55
|
+
public static function getSchemaPaths(): array
|
|
56
|
+
{
|
|
57
|
+
return static::$schemaPaths;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Clear all registered schema paths.
|
|
62
|
+
*
|
|
63
|
+
* @return void
|
|
64
|
+
*/
|
|
65
|
+
public static function clearSchemaPaths(): void
|
|
66
|
+
{
|
|
67
|
+
static::$schemaPaths = [];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Export schema paths to JSON file for CLI consumption.
|
|
72
|
+
*
|
|
73
|
+
* @param string|null $outputPath Path to write JSON file (defaults to storage/omnify/schema-paths.json)
|
|
74
|
+
* @return string Path to the generated file
|
|
75
|
+
*/
|
|
76
|
+
public static function exportPaths(?string $outputPath = null): string
|
|
77
|
+
{
|
|
78
|
+
$outputPath = $outputPath ?? storage_path('omnify/schema-paths.json');
|
|
79
|
+
|
|
80
|
+
$dir = dirname($outputPath);
|
|
81
|
+
if (!is_dir($dir)) {
|
|
82
|
+
mkdir($dir, 0755, true);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
$data = [
|
|
86
|
+
'generated_at' => now()->toIso8601String(),
|
|
87
|
+
'paths' => static::$schemaPaths,
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
file_put_contents($outputPath, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
|
91
|
+
|
|
92
|
+
return $outputPath;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace App\Console\Commands;
|
|
4
|
+
|
|
5
|
+
use App\Support\Omnify;
|
|
6
|
+
use Illuminate\Console\Command;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Sync registered schema paths for Omnify CLI.
|
|
10
|
+
*
|
|
11
|
+
* This command exports all schema paths registered by Laravel packages
|
|
12
|
+
* to a JSON file that the Omnify CLI can read.
|
|
13
|
+
*
|
|
14
|
+
* @generated by @famgia/omnify-laravel
|
|
15
|
+
*/
|
|
16
|
+
class OmnifySyncCommand extends Command
|
|
17
|
+
{
|
|
18
|
+
/**
|
|
19
|
+
* The name and signature of the console command.
|
|
20
|
+
*
|
|
21
|
+
* @var string
|
|
22
|
+
*/
|
|
23
|
+
protected $signature = 'omnify:sync
|
|
24
|
+
{--output= : Custom output path for schema-paths.json}';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The console command description.
|
|
28
|
+
*
|
|
29
|
+
* @var string
|
|
30
|
+
*/
|
|
31
|
+
protected $description = 'Export registered schema paths for Omnify CLI';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Execute the console command.
|
|
35
|
+
*/
|
|
36
|
+
public function handle(): int
|
|
37
|
+
{
|
|
38
|
+
$this->info('Syncing Omnify schema paths...');
|
|
39
|
+
|
|
40
|
+
// Get all registered paths
|
|
41
|
+
$paths = Omnify::getSchemaPaths();
|
|
42
|
+
|
|
43
|
+
if (empty($paths)) {
|
|
44
|
+
$this->warn('No additional schema paths registered by packages.');
|
|
45
|
+
$this->line('Tip: Packages can register schemas using:');
|
|
46
|
+
$this->line(' Omnify::addSchemaPath(__DIR__.\'/../database/schemas\');');
|
|
47
|
+
} else {
|
|
48
|
+
$this->line('Found ' . count($paths) . ' registered schema path(s):');
|
|
49
|
+
foreach ($paths as $entry) {
|
|
50
|
+
$namespace = $entry['namespace'] ? " [{$entry['namespace']}]" : '';
|
|
51
|
+
$this->line(" • {$entry['path']}{$namespace}");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Export to JSON
|
|
56
|
+
$outputPath = $this->option('output');
|
|
57
|
+
$filePath = Omnify::exportPaths($outputPath);
|
|
58
|
+
|
|
59
|
+
$this->info("✓ Schema paths exported to: {$filePath}");
|
|
60
|
+
$this->newLine();
|
|
61
|
+
$this->line('Now run: <fg=cyan>npx omnify generate</> to regenerate with all schemas.');
|
|
62
|
+
|
|
63
|
+
return Command::SUCCESS;
|
|
64
|
+
}
|
|
65
|
+
}
|