@famgia/omnify-laravel 0.0.81 → 0.0.83
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-WFEVU3LX.js → chunk-TBXCIKK7.js} +39 -10
- package/dist/chunk-TBXCIKK7.js.map +1 -0
- package/dist/index.cjs +38 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +38 -9
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-WFEVU3LX.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -334,9 +334,10 @@ declare function getModelPath(model: GeneratedModel): string;
|
|
|
334
334
|
*
|
|
335
335
|
* @param existingContent - Existing file content (null if file doesn't exist)
|
|
336
336
|
* @param laravelVersion - Laravel version type
|
|
337
|
+
* @param laravelRoot - Laravel root directory (e.g., "./backend" or "")
|
|
337
338
|
* @returns Registration result or null if already registered
|
|
338
339
|
*/
|
|
339
|
-
declare function generateProviderRegistration(existingContent: string | null, laravelVersion: 'laravel11+' | 'laravel10-'): ProviderRegistrationResult | null;
|
|
340
|
+
declare function generateProviderRegistration(existingContent: string | null, laravelVersion: 'laravel11+' | 'laravel10-', laravelRoot?: string): ProviderRegistrationResult | null;
|
|
340
341
|
|
|
341
342
|
/**
|
|
342
343
|
* Laravel Factory Generator
|
package/dist/index.d.ts
CHANGED
|
@@ -334,9 +334,10 @@ declare function getModelPath(model: GeneratedModel): string;
|
|
|
334
334
|
*
|
|
335
335
|
* @param existingContent - Existing file content (null if file doesn't exist)
|
|
336
336
|
* @param laravelVersion - Laravel version type
|
|
337
|
+
* @param laravelRoot - Laravel root directory (e.g., "./backend" or "")
|
|
337
338
|
* @returns Registration result or null if already registered
|
|
338
339
|
*/
|
|
339
|
-
declare function generateProviderRegistration(existingContent: string | null, laravelVersion: 'laravel11+' | 'laravel10-'): ProviderRegistrationResult | null;
|
|
340
|
+
declare function generateProviderRegistration(existingContent: string | null, laravelVersion: 'laravel11+' | 'laravel10-', laravelRoot?: string): ProviderRegistrationResult | null;
|
|
340
341
|
|
|
341
342
|
/**
|
|
342
343
|
* Laravel Factory Generator
|
package/dist/index.js
CHANGED
package/dist/plugin.cjs
CHANGED
|
@@ -2144,12 +2144,14 @@ function generateModels(schemas, options) {
|
|
|
2144
2144
|
function getModelPath(model) {
|
|
2145
2145
|
return model.path;
|
|
2146
2146
|
}
|
|
2147
|
-
function generateProviderRegistration(existingContent, laravelVersion) {
|
|
2147
|
+
function generateProviderRegistration(existingContent, laravelVersion, laravelRoot = "") {
|
|
2148
2148
|
const providerClass = "App\\Providers\\OmnifyServiceProvider::class";
|
|
2149
2149
|
const providerLine = ` ${providerClass},`;
|
|
2150
|
+
const bootstrapPath = laravelRoot ? `${laravelRoot}/bootstrap/providers.php` : "bootstrap/providers.php";
|
|
2151
|
+
const configPath = laravelRoot ? `${laravelRoot}/config/app.php` : "config/app.php";
|
|
2150
2152
|
if (existingContent && existingContent.includes("OmnifyServiceProvider")) {
|
|
2151
2153
|
return {
|
|
2152
|
-
path: laravelVersion === "laravel11+" ?
|
|
2154
|
+
path: laravelVersion === "laravel11+" ? bootstrapPath : configPath,
|
|
2153
2155
|
content: existingContent,
|
|
2154
2156
|
laravelVersion,
|
|
2155
2157
|
alreadyRegistered: true
|
|
@@ -2169,14 +2171,14 @@ function generateProviderRegistration(existingContent, laravelVersion) {
|
|
|
2169
2171
|
result.push(line);
|
|
2170
2172
|
}
|
|
2171
2173
|
return {
|
|
2172
|
-
path:
|
|
2174
|
+
path: bootstrapPath,
|
|
2173
2175
|
content: result.join("\n"),
|
|
2174
2176
|
laravelVersion,
|
|
2175
2177
|
alreadyRegistered: false
|
|
2176
2178
|
};
|
|
2177
2179
|
} else {
|
|
2178
2180
|
return {
|
|
2179
|
-
path:
|
|
2181
|
+
path: bootstrapPath,
|
|
2180
2182
|
content: `<?php
|
|
2181
2183
|
|
|
2182
2184
|
return [
|
|
@@ -2218,7 +2220,7 @@ ${providerLine}
|
|
|
2218
2220
|
const lastNewline = beforeClose.lastIndexOf("\n");
|
|
2219
2221
|
const content = existingContent.substring(0, lastNewline + 1) + providerLine + "\n" + existingContent.substring(lastNewline + 1);
|
|
2220
2222
|
return {
|
|
2221
|
-
path:
|
|
2223
|
+
path: configPath,
|
|
2222
2224
|
content,
|
|
2223
2225
|
laravelVersion,
|
|
2224
2226
|
alreadyRegistered: false
|
|
@@ -3312,6 +3314,17 @@ function getModuleName2(schema) {
|
|
|
3312
3314
|
}
|
|
3313
3315
|
return "";
|
|
3314
3316
|
}
|
|
3317
|
+
function getFieldExpression(fieldName, propDef) {
|
|
3318
|
+
switch (propDef.type) {
|
|
3319
|
+
case "Date":
|
|
3320
|
+
return `$this->${fieldName}?->toDateString()`;
|
|
3321
|
+
case "DateTime":
|
|
3322
|
+
case "Timestamp":
|
|
3323
|
+
return `$this->${fieldName}?->toISOString()`;
|
|
3324
|
+
default:
|
|
3325
|
+
return `$this->${fieldName}`;
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3315
3328
|
function getPropertyOutput(propName, propDef, schemas, options) {
|
|
3316
3329
|
const snakeName = toSnakeCase(propName);
|
|
3317
3330
|
const lines = [];
|
|
@@ -3358,7 +3371,8 @@ function getPropertyOutput(propName, propDef, schemas, options) {
|
|
|
3358
3371
|
}
|
|
3359
3372
|
return lines;
|
|
3360
3373
|
}
|
|
3361
|
-
|
|
3374
|
+
const expression = getFieldExpression(snakeName, propDef);
|
|
3375
|
+
lines.push(` '${snakeName}' => ${expression},`);
|
|
3362
3376
|
return lines;
|
|
3363
3377
|
}
|
|
3364
3378
|
function generateResourceBase(schema, schemas, options) {
|
|
@@ -3507,6 +3521,18 @@ function getResourcePath(resource) {
|
|
|
3507
3521
|
}
|
|
3508
3522
|
|
|
3509
3523
|
// src/plugin.ts
|
|
3524
|
+
function inferLaravelRoot(providersPath) {
|
|
3525
|
+
const normalized = providersPath.replace(/\\/g, "/");
|
|
3526
|
+
const match = normalized.match(/^(.*)\/app\/Providers\/?$/i);
|
|
3527
|
+
if (match && match[1]) {
|
|
3528
|
+
return match[1];
|
|
3529
|
+
}
|
|
3530
|
+
const baseMatch = normalized.match(/^(.*)\/app\/Providers\/OmnifyBase\/?$/i);
|
|
3531
|
+
if (baseMatch && baseMatch[1]) {
|
|
3532
|
+
return baseMatch[1];
|
|
3533
|
+
}
|
|
3534
|
+
return "";
|
|
3535
|
+
}
|
|
3510
3536
|
function getExistingMigrationTables(migrationsDir) {
|
|
3511
3537
|
const existingTables = /* @__PURE__ */ new Set();
|
|
3512
3538
|
if (!(0, import_node_fs.existsSync)(migrationsDir)) {
|
|
@@ -3776,8 +3802,11 @@ function laravelPlugin(options) {
|
|
|
3776
3802
|
schemaName: model.schemaName
|
|
3777
3803
|
}
|
|
3778
3804
|
}));
|
|
3779
|
-
const
|
|
3780
|
-
const
|
|
3805
|
+
const laravelRoot = inferLaravelRoot(resolved.providersPath);
|
|
3806
|
+
const bootstrapProvidersRelPath = laravelRoot ? `${laravelRoot}/bootstrap/providers.php` : "bootstrap/providers.php";
|
|
3807
|
+
const configAppRelPath = laravelRoot ? `${laravelRoot}/config/app.php` : "config/app.php";
|
|
3808
|
+
const bootstrapProvidersPath = (0, import_node_path.join)(ctx.cwd, bootstrapProvidersRelPath);
|
|
3809
|
+
const configAppPath = (0, import_node_path.join)(ctx.cwd, configAppRelPath);
|
|
3781
3810
|
let existingContent = null;
|
|
3782
3811
|
let laravelVersion;
|
|
3783
3812
|
if ((0, import_node_fs.existsSync)(bootstrapProvidersPath)) {
|
|
@@ -3797,7 +3826,7 @@ function laravelPlugin(options) {
|
|
|
3797
3826
|
} else {
|
|
3798
3827
|
laravelVersion = "laravel11+";
|
|
3799
3828
|
}
|
|
3800
|
-
const registration = generateProviderRegistration(existingContent, laravelVersion);
|
|
3829
|
+
const registration = generateProviderRegistration(existingContent, laravelVersion, laravelRoot);
|
|
3801
3830
|
if (registration && !registration.alreadyRegistered) {
|
|
3802
3831
|
outputs.push({
|
|
3803
3832
|
path: registration.path,
|