dox 3.2.4
dox: ^3.2.4 copied to clipboard
This is a cli tool to generate migration, model and to handle database migration with dox framework. It support up and down methods to control migration version.
3.2.4 #
- New:
dox make:serializer Post --folderputs the file inlib/app/serializers/post/. Without--folder, the file goes inlib/app/serializers/, as before. - New: when the dox_annotation of the app has
@Serialize(),dox make:serializeradds@Serialize()and thepartline to the new file. Then the serializer writes its JSON with noMapin between. Rundox build_runner:buildto make the.g.dartfile. With an older dox_annotation, the file has no@Serialize(), so it compiles.
3.2.3 #
- Fix:
seeders.dartandmigrations.dartlisted anabstractorsealedclass, likeabstract class BaseSeeder extends Seeder, and called its constructor. The app did not compile. These classes are now skipped. A class that extends an abstract base class (class UserSeeder extends BaseSeeder), also in another file or through more than one level, is now found and listed. A file with only skipped classes is not imported. In a migration file, the first class that can be built is used. An annotation like@sealedor a comment word likeabstractis not read as a modifier. The scan also reads generic classes (class C extends Base<int>), skips commented-out code and text in strings, skips private classes (_Name, but they can still be a parent), and, for migrations, reads a base class from any.dartfile ofdb/migration(only timestamped files are registered).
3.2.2 #
- Fix:
dox key:generatedid not see anexport APP_KEY=oldline. It added a newAPP_KEYat the top, but the old line came later and won, so the app kept the old key. It still said the key was updated. Now it changes theexport APP_KEYline in place and keeps theexport. When.envhas more than oneAPP_KEYline, each one gets the new key, so no old key is left to win. A newAPP_KEYline in a file with Windows line ends (CRLF) now gets a CRLF end too. - Fix:
dox env:checkalways read.envwithenvExpandoff. WithenvExpandon in the app,APP_PORT=${PORT}gave a false "must be an int" error, and"..."escapes were read in another way than the app reads them. Now the check has a mode.dox env:checkchecks withenvExpandoff, like an app that does not setEnv.flags.dox env:check --expandchecks withenvExpandon. The result is whatAppEnv.load()gives with those flags. The first line of the output says which mode was used. WithenvExpandoff, when a value of.envwould change withenvExpandon, a note says to rundox env:check --expandif the app turns onenvExpand. It uses the same rules as dox_core, so'${...}', a${...}after#and an unknown${NAME}give no note. The note does not change the exit code. An unknown option now stops with exit code 1. Whenenv.g.dartis not made yet, it says to rundart run build_runner buildand exits with code 1, instead of showing Dart compiler errors. - Fix:
dox env:generatemade code that does not compile forexport APP_NAME=dox(String get export appName;) and for a key likeCLASS(a Dart reserved word). Nowexportis removed. A reserved word or a name that starts with a digit getsenvin front (CLASSgivesenvClass) and an@EnvKey('CLASS'). - Fix:
dox env:generatemadeZIP=02134anintand lost the leading zero. A number with a leading zero is now aString. - Fix:
dox env:generatewrote the example value of a secret into the code when it looked like a number or a bool (DB_PASSWORD=123456gaveint get dbPassword => 123456;). Now a key that hasPASS,PW,SECRET,KEY,TOKEN,SALT,CREDENTIAL,PRIVATE,AUTH,JWT,DSN,OTP,PIN,CERT,SIGN,CODE,CVV,CVC,HMAC,SEED,NONCE,SSN,HASHorLICENSEanywhere in its name (APIKEY,PASSCODE,PIN) is always aStringwith no default. This is too safe on purpose:TOKEN_TTL=3600also gets no default..env.exampleis in git, so never put a real secret in it. Read the made class before you commit it. - Fix:
dox env:generatewrote@EnvKey('$key')as it is. A key with$,'or\gave code that does not compile. The key is now escaped. - Fix:
dox env:generatemade code that does not compile for a number over 64 bits (now aString), for two keys with the same getter name (A_BandA__B: the later one getsaB2and an@EnvKey), and for keys that clash with a member of the class or of the generated code (LOAD,HASH_CODE,TO_STRING,R,INT: they getenvin front and an@EnvKey). dox env:generateadds@EnvKey('KEY')when the getter name could give another key, also under the acronym rule of dox_builder (aBCcan beA_B_CorA_BC). So each getter reads the right key with an old and a new dox_builder.
3.2.1 #
- New:
dox servehot reloads code changes. When only files inlib/app/change (controllers, services, models and so on), dox reloads the new code into the running server, with no restart. It takes about 0.1 s. It works for all isolates of the server. A hot reload does not wait for build_runner. Changes in routes, providers, config,lib/generated/,bin/,db/and generated.g.dartfiles still restart the server, because that code or data is built only at start. A hot reload also does not re-run code that already ran inlib/app/, like a static value or an object made at start. When a change does not show, restart dox. When a reload fails (for example a compile error), the server restarts. The server now runs with the Dart VM service on a free localhost port, with DevTools. The server prints the VM service link at start. Open it in a browser to get DevTools. Use it for the debugger, the CPU profiler and memory snapshots. VS Code can also attach to the VM service address.dox serve --no-reloadturns hot reload off. dox serveruns one reload or restart at a time, so quick saves never start a second server. A server or build_runner that ignores SIGTERM gets SIGKILL after 5 seconds, on a restart and when dox stops. A hot reload has a 10 second limit, so a stuck server can not hang dox. When build_runner prints nothing for 60 seconds during a build, dox stops waiting for it. dox now also stops when the terminal closes (SIGHUP), and a second Ctrl+C while it stops exits at once (other signals let the first stop finish). A server or build_runner that starts while dox stops is stopped too. A resident compiler left by a dox that was killed (SIGKILL) is stopped at the nextdox serve. Errors and warnings ofbuild_runner watchare now shown (progress lines are not). Eachdox servehas its own resident compiler, so a seconddox servein the same project is not affected when the first one stops.- Faster
dox serve(dox s) restarts. The server now runs withdart run --resident, so a restart only compiles the changed files. The resident compiler uses an info file in.dart_tool/dox/, and dox stops it when dox exits. Changes inbuild/and in hidden folders like.dart_tool/no longer restart the server. The wait after a change is now 200 ms (was 500 ms). With build_runner, one save gives one restart: dox waits until build_runner has written the new generated files. Before, the server restarted on the save and again for each generated file. The server now starts first, andbuild_runner watchstarts when the server says "Server started at" (or after 10 seconds). Before, both started at the same time and slowed down each other. When the first build writes new files, the server restarts once after it.
3.2.0 #
- New:
dox add <package>adds a Dox package and sets it up.ormis short fordox_orm. It runsdart pub add(with--devwhen given),dart pub get, then the<package>:installcommand of the package. The other words go to that command, likedox add orm --driver=postgres. A package with no install command is only added, anddox addsays so. When the package commands can not be loaded (a broken commands library), it prints an error and exits with code 1. The name is the first word that is not a flag, sodox add --dev ormworks. The CLI has no code of any package. - The hints of
dox queue:*(whenbin/queue.dartis missing) anddox make:job(when dox_queue is not in pubspec.yaml) now say: for the database driver or batches, adddox_queue_databaseand make the queue provider extendDatabaseQueueProvider. - New:
dox route:listprints every route of the app: method, path, name, handler and middleware. It does not start the server. It writes a small script into.dart_tool/dox/and runs it. The script loads the routes of the app routers withDox().loadRoutes(), so it needs a dox_core with that call. Providers do not run, so a route that a provider adds insetup()(like the Socket.IO mount) is not listed. Fallback routes show asFALLBACK,Route.mounthandlers asMOUNT(with the global middleware formiddleware: true). ARoute.websocketroute showsWebSocketas its handler (fromRouteData.isWebSocket). Errors go to stderr, so--jsonoutput stays clean.dox route:list --jsonprints the same data as JSON. - New: five
make:commands.dox make:provider <name>makeslib/providers/<name>_provider.dart(aDoxProviderwithsetup()).dox make:command <name>makeslib/app/commands/<name>_command.dart, adds it tolib/app/commands/commands.dart, and setsdox: commands:in pubspec.yaml when it is missing.dox make:mail <name>makes aMailableinlib/app/mail/and its viewresources/views/emails/<name>.dox.html.--no-viewmakes a mail with a plain text body and no view.dox make:view <name>makes a.dox.htmlfile inresources/views(emails/welcomemakes a folder).dox make:test <name>makestest/<name>_test.dartwith aDoxTestClient.--unitmakes a plainpackage:testtest. None of them overwrites a file. A bad name, an extra word or an unknown flag prints an error and exits with code 1. - New:
dox schedule:clear-cacherunsbin/schedule.dart clear-cache. A crash can leave thewithoutOverlapping()lock of a task in the cache, so the task is skipped for up to 24 hours. The command removes these locks. It needs a dox_scheduler withclear-cache. Do not run it while a task really runs on another process. - New:
dox make:modeltakes Laravel style flags.-m(--migration) makes the migration,-c(--controller) a controller,-r(--resource) a resource controller,--apia resource controller withoutcreateandedit,-f(--factory) a factory,-s(--seed) a seeder, and-a(--all) the migration, factory, seeder and resource controller. Short flags can be joined, like-mcr. Each file is the same as the one the single command makes, likedox make:factory Post. A resource controller frommake:modeluses the model. When the model exists, nothing is made, as before with-m. - New:
dox make:controllertakes--resource(the same as-r),--api(a resource controller withoutcreateandedit) and--model=Postor--model Post(a resource controller whose actions use thePostmodel). It prints a warning when the model file does not exist yet. - Fix:
dox make:controller Photo --resourcemade a plain controller and gave no error.dox make:model Post -mcfailed. Now an unknown flag ofmake:modelormake:controllerprints an error and exits with code 1, and nothing is made. An extra word, likedox make:controller Photo junk, does the same. Before, it made a plain controller. - New:
dox migration:rollback --batch=3(or--batch 3) rolls back only the migrations of batch 3. It is passed on tobin/migrate.dart, like--step. It needs a dox_migration withrollback --batch. Give--stepor--batch, not both. - Fix:
dox queue:prune-failed --hours 48(with a space) now works, like--hours=48. Before, it was refused. Any other second word still prints the usage and stops with exit code 1. - Fix:
dox make:migrationwrotedb/migration/migrations.dartin a shape thatdart formatchanged later. Now the file is written indart formatshape. Short entries are on one line, and long imports are split. - Fix: the help of
dox queue:clearnow says "Delete the jobs of a queue". With Redis it also deletes the delayed and reserved jobs, not only the waiting ones. The help ofdox queue:restartnow says it needs a shared cache store.
3.1.1 #
- Change:
dox make:serializernow makes the file inlib/app/serializers/(before:lib/app/http/serializers/). Serializers are used by more than HTTP (MCP, websocket). The model import in the file is now a package import:package:<app>/app/models/<name>/<name>.model.dart. The app name comes frompubspec.yaml. Without a name, the command prints a message and stops (same asdox make:factory).
3.1.0 #
- New:
dox queue:clear [queue],dox queue:restartanddox queue:prune-failed [--hours=N]. They runbin/queue.dart clear|restart|prune-failed. They need a dox_queue that has these commands.dox help queue:worknow also lists--backoff,--max-jobs,--max-timeand--memory. - Fix: another
doxcan delete.dart_tool/dox/commands.dartwhile this run reads it. This run crashed then. Now it writes the file again from the cache and goes on. - Fix: an unknown command in an app with package commands (like an app with dox_queue) now exits with code 1. Before, it printed "Could not find a command" and exited with 0. An app that already has
.dart_tool/dox/commands.dartgets the new file on the next run. - Fix: the model from
dox make:modelhas nounintended_html_in_doc_commentinfo any more. The<String>[...]example in its doc comment is now in backticks. - New: package commands. A package (or the app) adds
doxcommands with thedox: commands:key in its pubspec.yaml, likedox: {commands: package:dox_queue/commands.dart}.dox <name>finds them when the name is not a built-in command. It reads.dart_tool/package_config.json, writes.dart_tool/dox/commands.dart, and runs it withdart run. The exit code of the command is the exit code ofdox. The file is written again only when package_config.json or a pubspec.yaml change. - A built-in command always wins. Two packages with the same command name print an error (exit code 1). A bad
dox: commands:key prints a warning, and the other packages still work. dox helplists the package commands, one group per package.dox help <name>shows one package command. Outside an app, or when no package has commands, it does not start Dart.- An unknown command now also prints a hint about the
dox: commands:key. dox migrate(and the othermigration:*commands) now makesbin/migrate.dartwhen it is missing anddb/migrationhas Dart migrations, then goes on. Before, it stopped with "bin/migrate.dart is missing". So a migration that a package command wrote (likedox queue:table) runs withdox migrate.- The commands are found in an app inside a pub workspace too. A member finds the workspace root from
.dart_tool/pub/workspace_ref.json(so a glob likeapps/*works). - The file is also written again when the pubspec.yaml of any package changes (like a path dependency), with no
dart pub get. A run with warnings (like a commands library that is not there yet) is not cached, so a fix counts on the next run. The files are written with write-then-rename. - A
dox: commands:value must be a plain path likepackage:<name>/<path>.dart(no.., no quotes). Else the package is skipped with a warning. - Only the packages that the app uses count (from
.dart_tool/package_graph.json). In a pub workspace, an app does not see the commands of other members. - A commands library that is removed after the cache was made is skipped with a warning on the next run. The other packages still work.
dox help <name>says when more than one command has that name.- When a package command throws,
doxprints the error and its stack trace, and exits with code 1. - Now depends on
cryptoandyamldirectly (they were already used through other packages). - Safety:
dox migration:fresh,migration:resetandmigration:refreshdrop all tables. WhenAPP_ENV=productionand stdin is a terminal, they now ask first. Any answer other thanystops with exit code 1.--forceskips the question. Without a terminal (CI, deploy scripts) they print a warning and run as before. - Fix:
doxexited with code 0 when there was no command, the command was unknown, the arguments were wrong, or the command threw. Now it exits with code 1, so scripts and CI see the failure. - Fix:
dox make:model Postwrote@DoxModel(), so the ORM read the tablepost. Butmake:model Post -mmakes the tableposts. Now the model always gets the same plural table:@DoxModel(table: 'posts'). - The
make:modelstub now has an emptyfillablelist with a comment. A model is guarded by default, socreate(req.body)throwsMassAssignmentExceptionuntil you list the columns there. dox serve --port=8080(or any other unknown option) was ignored with no message. Now it prints a warning that says to setAPP_PORTin.env(or runAPP_PORT=8080 dox serve). The server still starts, as before.- Safety:
dox migration:rollbacknow has the same production check asmigration:fresh. WhenAPP_ENV=productionand stdin is a terminal, it asks first.--forceskips the question, likemigration:rollback --step=2 --force. dox migrate --force(and the othermigration:*commands without the check) still takes--forcewith no error. It does nothing there and is not passed on tobin/migrate.dart.- Safety:
dox key:generatechangesAPP_KEY, which logs out every user. WhenAPP_ENV=productionand stdin is a terminal, it now asks first, likemigration:fresh. Any answer other thanystops with exit code 1 and changes nothing.--forceskips the question. Without a terminal (CI, deploy scripts) it prints a warning and changes the key as before. Outside production it works as before. - New:
dox key:generate --showprints a new key and writes nothing. An unknown option is still ignored, as before, but now it prints a warning to stderr, soKEY=$(dox key:generate --show)holds only the key. - Fix:
dox migration:rollback --step 2(with a space) was rejected. Now it works, like--step=2.--stepgiven twice (like--step=2 --step=3) used the last value with no message. Now it prints an error and exits with code 1. - Fix: the
dox servewarning for an unknown option always saidAPP_PORT=8080. Now it shows the port of--port=<number>, likeAPP_PORT=3000for--port=3000. Any other option still shows 8080.
3.0.1 #
- Fix: when only
dox servegot SIGTERM or SIGINT (eg.kill <pid>from a script), the server andbuild_runner watchit started kept running and held the port. Now dox stops them first, waits up to 5 seconds, then exits. Ctrl+C in a terminal already worked.
3.0.0 #
- The CLI moved to its own repo: dartondox/dox-cli. It is the same code.
3.0.0-rc.2 #
- Fix:
dox createanddox updatesorted pre-releases only by their number, so3.0.0-alpha.17looked newer than3.0.0-rc.1.dox createthen cloned the alpha.17 template. Now the label counts first: alpha < beta < rc < stable. - Only the CLI has this version. The other Dox packages stay at 3.0.0-rc.1.
3.0.0-rc.1 #
- Fix:
dox make:jobwrote abin/queue.dartthat did not compile. It calledQueueWorker(jobs: ...), butQueueWorkerhas nojobsparameter. It now writes the same file as the app template:QueueWorker(app: appConfig). - Fix: the job that
dox make:jobwrites showedX(userId: 1).dispatch()in its comment. The class has nouserId. The comment now showsX().dispatch(). - Fix:
dox db:seed --class UserSeeder(with a space) was refused. Both--class=UserSeederand--class UserSeederwork now. - Fix:
dox make:middlewarewroteextends IDoxMiddleware. It now writesimplements IDoxMiddleware, like the docs and the built-in middleware. dox buildalso leaves the SQLite lock files of dox_migration (*.sqlite.lock,*.sqlite3.lock,*.db.lock) out ofbuild/bundle/db.
3.0.0-alpha.17 #
- Uses dox_migration 3.0.0-alpha.12.
dox make:controller -r: thedestroystub shows how to give a 404 whendelete()deletes 0 rows.
3.0.0-alpha.16 #
- Version bump only, to match the other packages.
3.0.0-alpha.15 #
dox make:dto CreateBlognow writeslib/app/http/dtos/create_blog/create_blog.dto.dart. Each DTO has its own folder, like models. The.dto.g.dartfile is made next to it.
3.0.0-alpha.14 #
- Fix:
dox make:migrationrun more than once in the same second gave files with the same timestamp. Then the run order depended only on the name, which could break foreign keys. Now each new migration (.dartor.sql) sorts after every file already indb/migration. When needed, it uses the newest time plus 1 second.
3.0.0-alpha.13 #
- Version bump only, to match the other packages.
3.0.0-alpha.12 #
- Version bump only, to match the other packages.
3.0.0-alpha.11 #
dox buildalso buildsbin/queue.dartandbin/schedule.dartwhen they exist, tobuild/bundle/bin/queueandbuild/bundle/bin/schedule. Before, the worker and the scheduler had no production binary.- Fix:
dox buildcopied the local SQLite database (db/dox.sqlite, with its-waland-shmfiles) intobuild/bundle/db, so dev data went to production. SQLite files are now left out. dox --helpanddox -hshow the help, likedox help.
3.0.0-alpha.10 #
make:*is now the main name of every generator:make:controller,make:middleware,make:dto,make:serializerandmake:model, likemake:migration,make:factoryandmake:seeder. Thecreate:*names still work as aliases.- New
dox make:job <name>: makeslib/app/jobs/<name>.job.dartandbin/queue.dartwhen it is missing. It prints a hint to adddox_queueand to runbuild_runner. - New
dox queue:work,queue:failed,queue:retry,queue:forgetandqueue:flush: runbin/queue.dartwith the same flags. - New
dox schedule:work,schedule:run,schedule:listandschedule:test <name>: runbin/schedule.dart. - These commands pass the terminal through, send SIGINT and SIGTERM to the app script so a worker can stop by itself, and return its exit code. When the script is missing they print how to set it up.
3.0.0-alpha.9 #
dox make:controller(create:controller) writes@Inject()above the class, and no global controller instance. The file shows the typed route to use. The command says to runbuild_runner.- New
dox make:factory <model>: makesdb/factories/<model>.factory.dart. - New
dox make:seeder <name>: makesdb/seeders/<name>.seeder.dart, writes the seeder listdb/seeders/seeders.dartand makesbin/seed.dartwhen it is missing. - New
dox db:seed [--class=<name>]: runsbin/seed.dart. The default seeder isDatabaseSeeder. - New
dox migration:fresh(ormigrate:fresh): drops all tables, then runs all migrations. --seedaftermigration:run,migration:refreshormigration:freshruns the seeders when the migrations end well.
3.0.0-alpha.8 #
- Version bump only, to match the other packages.
3.0.0-alpha.7 #
- Breaking:
create:controllerno longer takes-ws. Dox uses Socket.IO for realtime now. See the Socket.IO docs for a namespace class. - Security:
dox createnow copies.env.exampleto.envand writes a new randomAPP_KEY. Before, every new app used the same public key from the template. You no longer runcp .env.example .env. - The
.env.exampleof the CLI has an emptyAPP_KEY. Rundox key:generateto set one.
3.0.0-alpha.6 #
- Fix:
dox key:generatedropped.envlines with more than one=(likeDATABASE_URL=postgres://u:p@h/db?sslmode=require). It also dropped comment lines. Now it only changes theAPP_KEYline. Every other line stays as it is. - Fix:
dox createcrashed withFailed to decode data using encoding 'utf-8'when the template had a binary file (for exampledb/dox.sqlite-shm). It now skips files that are not UTF-8 text. It only writes a file when its content changes.
3.0.0-alpha.5 #
- Fix:
dox create my_appwithout--versioncrashed with aRangeError. - Fix:
dox createpicked the GitHub "latest" template release, which skips pre-releases. During the 3.x alpha that gave the old 2.x template. It now takes the newest template with the same major version as the CLI. - Fix:
dox env:generatereadKEY=3000 # noteas text, not as anint. A#after a space is now a comment. - Fix:
dox updateran a plaindart pub global activate dox, which skips pre-releases. During the 3.x alpha it installed the old 2.x CLI. It now installs the newest version with the same major version as the CLI, from the pub.dev version list.
3.0.0-alpha.4 #
- Version bump only, to match the other packages.
3.0.0-alpha.3 #
- Version bump only, to match the other packages.
3.0.0-alpha.2 #
- Fix:
dox buildno longer passes--delete-conflicting-outputsto build_runner (it was removed and printed a warning). - Needs Dart 3.13 or newer.
- All dependencies updated to their latest versions.
dox buildnow runsdart build cli(AOT, with build hooks). The output isbuild/bundle/. Start it withcd build/bundle && ./bin/server.- New
dox create:dto <name>: makeslib/app/http/dtos/<name>.dto.dart.dox create:requestis removed. dox create:controller -rusesint idfor the resource methods.- New
dox openapi:generate [dir]. It runs the app'sbin/openapi.dartand writesopenapi.jsonandopenapi.yaml(defaultstorage/openapi). - New
dox env:generate: makeslib/config/env.dart(the typed env class) from.env.example. - New
dox env:check: loads the typed env and prints every missing or bad key (exit code 1).
3.0.0-alpha.1 #
- Version 3 of Dox. All Dox packages now share one version.
- Needs Dart 3.6 or newer.
- See the release notes for all main changes.
- Generated models import
package:dox_orm/dox_orm.dart.
2.0.1 #
- bug fix on dox create command
2.0.0 #
- Release stable version v2.0
2.0.0-alpha.3 #
- Fix migration issue
2.0.0-alpha.2 #
- Add option to create project with specific version
2.0.0-alpha.1 #
- Compatible with core version 2
1.1.1 #
- handle migration with dox_migration
- set default migration file with .sql
1.0.55 #
- Add command to create serializer
- Add help option
1.0.54 #
- update request template
- Add help option
1.0.53 #
- Added command to create form request
dox create:request Blog
1.0.52 #
- Added command to create websocket controller
1.0.51 #
- Initial version.