@omnifyjp/ts 6.7.8 → 6.7.10
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/cli.js
CHANGED
|
@@ -251,7 +251,8 @@ program
|
|
|
251
251
|
let phpOverwritten = 0;
|
|
252
252
|
let phpSkipped = 0;
|
|
253
253
|
let phpSkippedSibling = 0;
|
|
254
|
-
let
|
|
254
|
+
let phpShadowedOutOfSync = 0;
|
|
255
|
+
let phpShadowedAtRisk = 0;
|
|
255
256
|
const skippedSiblingExamples = [];
|
|
256
257
|
const writtenPaths = [];
|
|
257
258
|
for (const file of phpFiles) {
|
|
@@ -271,9 +272,17 @@ program
|
|
|
271
272
|
// the base generates. #171 — a redeclared $fillable shadows the
|
|
272
273
|
// parent's, so every property added afterwards is stripped on mass
|
|
273
274
|
// assignment with no error anywhere.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
const shadowResults = evaluateShadowingConflicts(existing, file.conflicts ?? []);
|
|
276
|
+
if (shadowResults.length > 0) {
|
|
277
|
+
if (shadowResults.some((r) => r.drift === 'out-of-sync')) {
|
|
278
|
+
phpShadowedOutOfSync++;
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
phpShadowedAtRisk++;
|
|
282
|
+
}
|
|
283
|
+
for (const result of shadowResults) {
|
|
284
|
+
console.warn(`[omnify-ts] ${relative(configDir, filePath)}: ${result.message}`);
|
|
285
|
+
}
|
|
277
286
|
}
|
|
278
287
|
continue;
|
|
279
288
|
}
|
|
@@ -322,9 +331,15 @@ program
|
|
|
322
331
|
console.log(` ${phpCreated} files created (user-editable)`);
|
|
323
332
|
if (phpSkipped > 0)
|
|
324
333
|
console.log(` ${phpSkipped} files skipped (already exist)`);
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
|
|
334
|
+
if (phpShadowedOutOfSync > 0 || phpShadowedAtRisk > 0) {
|
|
335
|
+
const summaryParts = [];
|
|
336
|
+
if (phpShadowedOutOfSync > 0) {
|
|
337
|
+
summaryParts.push(`${phpShadowedOutOfSync} editable file(s) already out of sync with the base`);
|
|
338
|
+
}
|
|
339
|
+
if (phpShadowedAtRisk > 0) {
|
|
340
|
+
summaryParts.push(`${phpShadowedAtRisk} shadow a generated property and will drift on the next schema change`);
|
|
341
|
+
}
|
|
342
|
+
console.warn(` ${summaryParts.join(', ')} (see warnings above).`);
|
|
328
343
|
}
|
|
329
344
|
if (phpSkippedSibling > 0) {
|
|
330
345
|
console.log(` ${phpSkippedSibling} user-editable stub(s) skipped (project sibling with same name found in subfolder)`);
|
|
@@ -11,7 +11,13 @@ export declare function shadowingPropertyConflicts(baseClass: string, baseArrayV
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function parseRedeclaredStringArray(source: string, prop: string): string[] | null;
|
|
13
13
|
export declare function formatShadowingDrift(baseValues: readonly string[], childValues: string[] | null): string;
|
|
14
|
+
export type ShadowingDrift = 'out-of-sync' | 'in-sync' | 'unknown';
|
|
15
|
+
export type ShadowingConflictResult = {
|
|
16
|
+
property: ShadowingEloquentProperty;
|
|
17
|
+
message: string;
|
|
18
|
+
drift: ShadowingDrift;
|
|
19
|
+
};
|
|
14
20
|
/**
|
|
15
21
|
* Evaluate shadowing conflicts for a skipped user-editable model file.
|
|
16
22
|
*/
|
|
17
|
-
export declare function evaluateShadowingConflicts(existingRaw: string, conflicts: readonly ShadowingPropertyConflict[]):
|
|
23
|
+
export declare function evaluateShadowingConflicts(existingRaw: string, conflicts: readonly ShadowingPropertyConflict[]): ShadowingConflictResult[];
|
|
@@ -92,12 +92,28 @@ export function formatShadowingDrift(baseValues, childValues) {
|
|
|
92
92
|
}
|
|
93
93
|
return parts.join('; ') + '.';
|
|
94
94
|
}
|
|
95
|
+
function classifyShadowingDrift(baseValues, childValues) {
|
|
96
|
+
if (!baseValues || baseValues.length === 0) {
|
|
97
|
+
return 'unknown';
|
|
98
|
+
}
|
|
99
|
+
if (childValues === null) {
|
|
100
|
+
return 'unknown';
|
|
101
|
+
}
|
|
102
|
+
const baseSet = new Set(baseValues);
|
|
103
|
+
const childSet = new Set(childValues);
|
|
104
|
+
const missing = baseValues.filter((v) => !childSet.has(v));
|
|
105
|
+
const extra = childValues.filter((v) => !baseSet.has(v));
|
|
106
|
+
if (missing.length === 0 && extra.length === 0) {
|
|
107
|
+
return 'in-sync';
|
|
108
|
+
}
|
|
109
|
+
return 'out-of-sync';
|
|
110
|
+
}
|
|
95
111
|
/**
|
|
96
112
|
* Evaluate shadowing conflicts for a skipped user-editable model file.
|
|
97
113
|
*/
|
|
98
114
|
export function evaluateShadowingConflicts(existingRaw, conflicts) {
|
|
99
115
|
const stripped = stripPhpComments(existingRaw);
|
|
100
|
-
const
|
|
116
|
+
const results = [];
|
|
101
117
|
for (const conflict of conflicts) {
|
|
102
118
|
if (hasIntentionalShadowMarker(existingRaw, conflict.property)) {
|
|
103
119
|
continue;
|
|
@@ -106,14 +122,18 @@ export function evaluateShadowingConflicts(existingRaw, conflicts) {
|
|
|
106
122
|
continue;
|
|
107
123
|
}
|
|
108
124
|
let message = conflict.hint;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
125
|
+
const baseValues = conflict.baseValues && conflict.baseValues.length > 0 ? conflict.baseValues : undefined;
|
|
126
|
+
const childValues = baseValues
|
|
127
|
+
? parseRedeclaredStringArray(existingRaw, conflict.property)
|
|
128
|
+
: null;
|
|
129
|
+
const drift = classifyShadowingDrift(baseValues, childValues);
|
|
130
|
+
if (baseValues) {
|
|
131
|
+
const driftText = formatShadowingDrift(baseValues, childValues);
|
|
132
|
+
if (driftText) {
|
|
133
|
+
message += ` ${driftText}`;
|
|
114
134
|
}
|
|
115
135
|
}
|
|
116
|
-
|
|
136
|
+
results.push({ property: conflict.property, message, drift });
|
|
117
137
|
}
|
|
118
|
-
return
|
|
138
|
+
return results;
|
|
119
139
|
}
|