@omnifyjp/ts 6.3.6 → 6.3.8

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
@@ -322,7 +322,17 @@ program
322
322
  // Laravel Pint when it's installed in the project. Same preset
323
323
  // the project's CI already uses, so codegen output stops failing
324
324
  // `pint --test` and devs no longer need a manual sweep after
325
- // every `omnify generate`. Silent no-op when Pint isn't found.
325
+ // every `omnify generate`.
326
+ //
327
+ // NOT a silent no-op when Pint is missing any more. It used to be, and that cost a
328
+ // consumer several investigation sessions: their CI regenerated without Pint on PATH,
329
+ // wrote 927 files differing from the committed (Pint-formatted) tree, and the only
330
+ // evidence was one ABSENT log line. It was read as a Linux/Darwin build divergence and
331
+ // chased as far as "pick a canonical platform" before anyone ran the two commands that
332
+ // settle it (godx-jp/godx-corebooks#108, reproduced exactly: hide `vendor/bin/pint`,
333
+ // regenerate, 927 files; restore it, 0).
334
+ //
335
+ // The opt-out (`OMNIFY_NO_PINT=1`) stays quiet — that one is a choice, not a surprise.
326
336
  if (writtenPaths.length > 0) {
327
337
  const pintResult = runPintFormat(writtenPaths);
328
338
  if (pintResult.ran) {
@@ -337,6 +347,11 @@ program
337
347
  }
338
348
  }
339
349
  }
350
+ else if (pintResult.skipped === 'pint-not-found') {
351
+ console.warn(` [omnify] Laravel Pint not found — ${writtenPaths.length} PHP file(s) written UNFORMATTED.`);
352
+ console.warn(' If this project commits generated PHP, the output will differ from a tree formatted by Pint.');
353
+ console.warn(' Run `composer install` before `omnify generate`, or set OMNIFY_NO_PINT=1 to silence this deliberately.');
354
+ }
340
355
  }
341
356
  // Orphan cleanup: when a schema is removed, renamed, flipped from
342
357
  // kind:object → kind:pivot, or opted out via `options.service: false`,
@@ -38,6 +38,12 @@ export interface PintFormatResult {
38
38
  exitStatus: number | null;
39
39
  /** Captured stderr when pint failed (status != 0). */
40
40
  errorMessage?: string;
41
+ /**
42
+ * Why the run did not happen, when `ran` is false. The caller needs the three apart: only
43
+ * `pint-not-found` is worth telling a human about, and it is the one that silently changes what
44
+ * gets written to disk (godx-jp/godx-corebooks#108 — 927 files, reproduced).
45
+ */
46
+ skipped?: 'no-php-files' | 'opted-out' | 'pint-not-found';
41
47
  }
42
48
  /**
43
49
  * Run Laravel Pint on the given PHP files (absolute paths). No-op if
@@ -63,21 +63,21 @@ export function findPintBinary(anyWrittenPhpPath) {
63
63
  */
64
64
  export function runPintFormat(writtenPhpPaths) {
65
65
  if (writtenPhpPaths.length === 0) {
66
- return { ran: false, pintPath: null, formattedCount: 0, exitStatus: null };
66
+ return { ran: false, pintPath: null, formattedCount: 0, exitStatus: null, skipped: 'no-php-files' };
67
67
  }
68
68
  // Opt-out (#174). The auto-run hides what the generators actually emit: a
69
69
  // template that Pint rewrites looks fine here and produces churn in every
70
70
  // project where Pint is absent or does not run. `OMNIFY_NO_PINT=1` is how
71
71
  // the repo's own fixture check measures the raw output.
72
72
  if (process.env.OMNIFY_NO_PINT === '1') {
73
- return { ran: false, pintPath: null, formattedCount: 0, exitStatus: null };
73
+ return { ran: false, pintPath: null, formattedCount: 0, exitStatus: null, skipped: 'opted-out' };
74
74
  }
75
75
  // Resolution walks up from a written file. Trying only the first one makes
76
76
  // it depend on emission order — a single file outside the Laravel root and
77
77
  // the whole run goes unformatted, silently. Try each until one resolves.
78
78
  const pintPath = writtenPhpPaths.reduce((found, path) => found ?? findPintBinary(path), null);
79
79
  if (!pintPath) {
80
- return { ran: false, pintPath: null, formattedCount: 0, exitStatus: null };
80
+ return { ran: false, pintPath: null, formattedCount: 0, exitStatus: null, skipped: 'pint-not-found' };
81
81
  }
82
82
  // Pint's working dir should be the Laravel project root (where
83
83
  // composer.json + pint.json live). The pint binary is at
@@ -128,9 +128,21 @@ export function toStoreRules(property, tableName, fkRuleType = 'integer') {
128
128
  case 'Date':
129
129
  case 'DateTime':
130
130
  case 'Timestamp':
131
- case 'Time':
132
131
  rules.push('date');
133
132
  break;
133
+ case 'Time':
134
+ // #181: NOT `date`. Laravel's `date` rule runs `strtotime()` and then
135
+ // rejects anything that did not carry a date, so every time-only value a
136
+ // `time` column exists to hold — "12:00", "12:00:00", "23:59:59" — fails
137
+ // it, and only `null` gets through. A form with a time field it is
138
+ // impossible to fill, and nothing red anywhere: the migration, the model,
139
+ // the cast and the TypeScript were all correct.
140
+ //
141
+ // Both formats, because a client that reads a value and sends it back
142
+ // must be accepted: MySQL returns `H:i:s`, while an `<input type="time">`
143
+ // submits `H:i`.
144
+ rules.push('date_format:H:i,H:i:s');
145
+ break;
134
146
  case 'Json':
135
147
  rules.push('array');
136
148
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/ts",
3
- "version": "6.3.6",
3
+ "version": "6.3.8",
4
4
  "description": "TypeScript model type generator from Omnify schemas.json",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",