Skip to content

v0.5.0 - a name identifies a module

Choose a tag to compare

@Synerdy Synerdy released this 30 Aug 22:17
· 18 commits to master since this release

Deleting a module could remove a neighbouring module's files

With both Blog and BlogPost present, Blog claimed every file whose name merely started with modsx-blog. So modsx:delete Blog removed config/modsx-blog-post.php — BlogPost's — and backing Blog up archived BlogPost's migrations into Blog's version. modsx:doctor reported the pair as an error, but nothing stopped the command.

The cause was that one name meant two different things:

resources/views/modsx-blog-admin/   ->  module BlogAdmin   (a module of its own)
config/modsx-blog-admin.php         ->  Blog's file, and BlogAdmin's too

A name identifies a module — in a file as much as in a directory

A file's name is now read exactly as a directory's is, cut at the first dot:

Path Module
config/modsx-blog.php Blog
resources/views/modsx-blog.blade.php Blog
lang/en/modsx-blog.php, lang/pl/modsx-blog.php Blog
config/modsx-blog-post.php BlogPost, and only BlogPost
config/modsx-blog-admin.php BlogAdmin

Module names are unique, so at most one module can match a file — two can never both claim one. Where a module genuinely needs several files in one place, the form is a directory: config/modsx-blog/settings.php, which Laravel reads as config('modsx-blog.settings').

Breaking: a file like config/modsx-blog-admin.php was Blog's and now is not. modsx:doctor lists every file naming a module that doesn't exist, under a new unclaimed_files key — without that, such a file would drop out of its backup silently. Existing backups are unaffected: restore reads the manifest, so a version gives back exactly what it recorded.

Migrations go to the longest module name that claims them

A migration is the one thing that cannot be named for its module and nothing else, since every migration needs its own name:

modsx_blog_create_posts_table          ->  Blog
modsx_blog_post_create_comments_table  ->  BlogPost, or Blog if BlogPost doesn't exist

Decided by the module list, with no vocabulary of migration verbs — make:migration accepts any name at all (backfill_, cleanup_), and module names are themselves sometimes verbs (Import, Update).

Blog alongside BlogPost is therefore a supported layout. modsx:doctor no longer counts it as a problem; it is listed informationally, stating how their migrations divide.

Also

  • confirmDestructive() moved into a trait used only by the three commands that declare --force. It had guarded itself with hasOption('force') because the other eleven did not have it — eleven static-analysis errors that a stale PHPStan cache had been hiding.
  • composer smoke runs a command by hand in a Testbench app, rebuilding package discovery first. Development only.

Full detail in the CHANGELOG.