aiiinotate 0.8.4 → 0.8.5

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.
Files changed (2) hide show
  1. package/cli/migrate.js +14 -8
  2. package/package.json +1 -1
package/cli/migrate.js CHANGED
@@ -15,9 +15,6 @@ import { execSync } from "node:child_process"
15
15
 
16
16
  import { Command, Option, Argument } from "commander";
17
17
 
18
- import loadMongoClient from "#cli/utils/mongoClient.js";
19
-
20
-
21
18
  /** @typedef {"make"|"apply"|"revert"|"revert-all"} MigrateOpType */
22
19
  const allowedMigrateOp = ["make", "apply", "revert", "revert-all"];
23
20
 
@@ -109,17 +106,26 @@ async function action(command, migrationOp, options) {
109
106
 
110
107
  function makeMigrateCommand() {
111
108
  const migrationOpArg =
112
- new Argument("<migration-op>", "name of migration operation").choices(allowedMigrateOp);
109
+ new Argument("<migration-op>", "name of migration operation")
110
+ .choices(allowedMigrateOp);
113
111
 
114
112
  const migrationNameOpt =
115
- new Option("-n, --migration-name <name>", "name of migration (for 'make' argument)")
116
- .makeOptionMandatory();
113
+ new Option("-n, --migration-name <name>", "name of migration (for 'make' argument)");
117
114
 
118
- return new Command("migrate")
115
+ const command = new Command("migrate");
116
+ return command
119
117
  .description("run database migrations")
120
118
  .addArgument(migrationOpArg)
121
119
  .addOption(migrationNameOpt)
122
- .action((migrationOp, options, command) => action(command, migrationOp, options))
120
+ .action((migrationOp, options, command) => {
121
+ if (
122
+ migrationOp == "make"
123
+ && (options.migrationName === undefined || options.migrationName === "")
124
+ ) {
125
+ command.error("migration operation \"apply\" requires option \"-n, --migration-name <name>\"", { exitCode: 1 });
126
+ }
127
+ action(command, migrationOp, options)
128
+ })
123
129
  }
124
130
 
125
131
  export default makeMigrateCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiiinotate",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "a fast IIIF-compliant annotation server",
5
5
  "main": "./cli/index.js",
6
6
  "type": "module",