@omnifyjp/ts 6.8.1 → 7.0.0

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
@@ -32,8 +32,6 @@ import { generatePhp, derivePhpConfig } from './php/index.js';
32
32
  import { evaluateShadowingConflicts } from './php/shadowing-conflicts.js';
33
33
  import { hasEditableSubclassForBase, pruneDisabledScaffoldLayerBases, pruneOrphanServiceFilesIfEnabled } from './php/orphan-cleanup.js';
34
34
  import { findSiblingWithSameBasename, findAppRootAncestor } from './php/sibling-skip.js';
35
- import { runPintFormat } from './php/pint-format.js';
36
- import { runPrettierFormat } from './prettier-format.js';
37
35
  import { resolveInput, sniffInputKind } from './input-resolver.js';
38
36
  function resolveFromConfig(configPath) {
39
37
  const raw = readFileSync(configPath, 'utf-8');
@@ -195,7 +193,6 @@ program
195
193
  let tsCreated = 0;
196
194
  let tsOverwritten = 0;
197
195
  let tsSkipped = 0;
198
- const tsWrittenPaths = [];
199
196
  for (const file of files) {
200
197
  let filePath;
201
198
  if (file.category === 'enum' || file.category === 'plugin-enum') {
@@ -210,7 +207,6 @@ program
210
207
  continue;
211
208
  }
212
209
  writeFileSync(filePath, file.content, 'utf-8');
213
- tsWrittenPaths.push(filePath);
214
210
  if (file.overwrite || !existsSync(filePath)) {
215
211
  tsOverwritten++;
216
212
  }
@@ -223,22 +219,6 @@ program
223
219
  console.log(` ${tsCreated} files created (user-editable)`);
224
220
  if (tsSkipped > 0)
225
221
  console.log(` ${tsSkipped} files skipped (already exist)`);
226
- // Issue #211: format via the consumer project's Prettier (same idea as Pint for PHP).
227
- if (tsWrittenPaths.length > 0) {
228
- const prettierResult = runPrettierFormat(tsWrittenPaths);
229
- if (prettierResult.ran) {
230
- if (prettierResult.exitStatus === 0) {
231
- console.log(` Formatted ${prettierResult.formattedCount} TS file(s) via Prettier`);
232
- }
233
- else {
234
- console.warn(` [omnify] Prettier exited with status ${prettierResult.exitStatus}; generated files may not match project formatting preset.`);
235
- if (prettierResult.errorMessage) {
236
- const trimmed = prettierResult.errorMessage.trim().split('\n').slice(0, 5).join('\n');
237
- console.warn(` ${trimmed}`);
238
- }
239
- }
240
- }
241
- }
242
222
  }
243
223
  else {
244
224
  console.log(`\n[TypeScript] Skipped (disabled)`);
@@ -259,7 +239,6 @@ program
259
239
  let phpShadowedOutOfSync = 0;
260
240
  let phpShadowedAtRisk = 0;
261
241
  const skippedSiblingExamples = [];
262
- const writtenPaths = [];
263
242
  for (const file of phpFiles) {
264
243
  const filePath = resolve(configDir, file.path);
265
244
  mkdirSync(dirname(filePath), { recursive: true });
@@ -323,7 +302,6 @@ program
323
302
  }
324
303
  }
325
304
  writeFileSync(filePath, file.content, 'utf-8');
326
- writtenPaths.push(filePath);
327
305
  if (file.overwrite || !existsSync(filePath)) {
328
306
  phpOverwritten++;
329
307
  }
@@ -355,41 +333,6 @@ program
355
333
  console.log(` ... and ${phpSkippedSibling - skippedSiblingExamples.length} more`);
356
334
  }
357
335
  }
358
- // Issue #100 v5.8.20: auto-format every written PHP file via
359
- // Laravel Pint when it's installed in the project. Same preset
360
- // the project's CI already uses, so codegen output stops failing
361
- // `pint --test` and devs no longer need a manual sweep after
362
- // every `omnify generate`.
363
- //
364
- // NOT a silent no-op when Pint is missing any more. It used to be, and that cost a
365
- // consumer several investigation sessions: their CI regenerated without Pint on PATH,
366
- // wrote 927 files differing from the committed (Pint-formatted) tree, and the only
367
- // evidence was one ABSENT log line. It was read as a Linux/Darwin build divergence and
368
- // chased as far as "pick a canonical platform" before anyone ran the two commands that
369
- // settle it (godx-jp/godx-corebooks#108, reproduced exactly: hide `vendor/bin/pint`,
370
- // regenerate, 927 files; restore it, 0).
371
- //
372
- // The opt-out (`OMNIFY_NO_PINT=1`) stays quiet — that one is a choice, not a surprise.
373
- if (writtenPaths.length > 0) {
374
- const pintResult = runPintFormat(writtenPaths);
375
- if (pintResult.ran) {
376
- if (pintResult.exitStatus === 0) {
377
- console.log(` Formatted ${pintResult.formattedCount} PHP file(s) via Laravel Pint`);
378
- }
379
- else {
380
- console.warn(` [omnify] Laravel Pint exited with status ${pintResult.exitStatus}; generated files may not match project formatting preset.`);
381
- if (pintResult.errorMessage) {
382
- const trimmed = pintResult.errorMessage.trim().split('\n').slice(0, 5).join('\n');
383
- console.warn(` ${trimmed}`);
384
- }
385
- }
386
- }
387
- else if (pintResult.skipped === 'pint-not-found') {
388
- console.warn(` [omnify] Laravel Pint not found — ${writtenPaths.length} PHP file(s) written UNFORMATTED.`);
389
- console.warn(' If this project commits generated PHP, the output will differ from a tree formatted by Pint.');
390
- console.warn(' Run `composer install` before `omnify generate`, or set OMNIFY_NO_PINT=1 to silence this deliberately.');
391
- }
392
- }
393
336
  // Orphan cleanup: when a schema is removed, renamed, flipped from
394
337
  // kind:object → kind:pivot, or opted out via `options.service: false`,
395
338
  // its previously-emitted `*ServiceBase.php` becomes orphan and
@@ -208,7 +208,7 @@ function generateUserController(name, schema, config) {
208
208
  className: `${modelName}ControllerBase`,
209
209
  fqn: `${resolveModularBaseNamespace(config, name, 'Controllers', config.controllers.baseNamespace)}\\${modelName}ControllerBase`,
210
210
  }
211
- : resolveBaseClass(config.controllers, `${modelName}Controller`, 'Base');
211
+ : legacyGroupedBase(config, `${modelName}Controller`, schema.group);
212
212
  const editable = config.structure === 'modular'
213
213
  ? { className: `${modelName}Controller`, fileName: `${modelName}Controller.php`, namespace: config.controllers.namespace, path: config.controllers.path }
214
214
  : resolveEditableClass(config.controllers, modelName, 'Controller');
@@ -244,3 +244,13 @@ class ${editable.className} extends ${baseAlias}
244
244
  `;
245
245
  return userFile(`${userPath}/${editable.fileName}`, content);
246
246
  }
247
+ /**
248
+ * Legacy layout nests the base controller under its schema group (see
249
+ * `generateBaseController`), so the stub must import it from the same nested
250
+ * namespace — a flat import names a class that does not exist.
251
+ */
252
+ function legacyGroupedBase(config, className, group) {
253
+ const raw = resolveBaseClass(config.controllers, className, 'Base');
254
+ const { namespace } = nestByGroup({ path: '', namespace: raw.namespace }, group);
255
+ return { className: raw.className, fqn: `${namespace}\\${raw.className}` };
256
+ }
@@ -43,7 +43,8 @@ export function buildRelation(propName, property, modelNamespace, context) {
43
43
  const related = relation === 'MorphTo'
44
44
  ? '\\Illuminate\\Database\\Eloquent\\Model'
45
45
  : '\\' + modelNamespace + '\\' + target;
46
- method = method.replace(' */', ` * @return ${type}<${related}, $this>\n */`);
46
+ // Blank line before the tag: Pint's `phpdoc_separation` (laravel preset).
47
+ method = method.replace(' */', ` *\n * @return ${type}<${related}, $this>\n */`);
47
48
  return { method, imports };
48
49
  }
49
50
  /** Generate the table name Laravel's joiningTable() infers from model basenames. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/ts",
3
- "version": "6.8.1",
3
+ "version": "7.0.0",
4
4
  "description": "TypeScript model type generator from Omnify schemas.json",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",