@13w/miri 1.1.25 → 1.1.26
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 +77 -25
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -187,12 +187,17 @@ const getMiri = async () => {
|
|
|
187
187
|
};
|
|
188
188
|
const status = async (remote = false, group, all = false) => {
|
|
189
189
|
const miri = await getMiri();
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
let patches;
|
|
191
|
+
try {
|
|
192
|
+
patches = await miri.stat(remote, group);
|
|
193
|
+
if (!group && all) {
|
|
194
|
+
const initPatches = await miri.stat(remote, 'init');
|
|
195
|
+
patches.unshift(...initPatches);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
await miri[Symbol.asyncDispose]();
|
|
194
200
|
}
|
|
195
|
-
await miri[Symbol.asyncDispose]();
|
|
196
201
|
if (!patches.length) {
|
|
197
202
|
return;
|
|
198
203
|
}
|
|
@@ -252,10 +257,14 @@ program
|
|
|
252
257
|
.option('--all', 'Re-apply all patches')
|
|
253
258
|
.action(async (opts) => {
|
|
254
259
|
const miri = await getMiri();
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
260
|
+
try {
|
|
261
|
+
await miri.init({ force: opts.all });
|
|
262
|
+
await syncIndexes(miri);
|
|
263
|
+
await miri.sync(opts);
|
|
264
|
+
}
|
|
265
|
+
finally {
|
|
266
|
+
await miri[Symbol.asyncDispose]();
|
|
267
|
+
}
|
|
259
268
|
});
|
|
260
269
|
const initProgram = program.command('init').description('Manage initial scripts');
|
|
261
270
|
initProgram
|
|
@@ -265,8 +274,12 @@ initProgram
|
|
|
265
274
|
.option('--force', 'Force apply patch')
|
|
266
275
|
.action(async (patch, opts) => {
|
|
267
276
|
const miri = await getMiri();
|
|
268
|
-
|
|
269
|
-
|
|
277
|
+
try {
|
|
278
|
+
await miri.init(opts, patch);
|
|
279
|
+
}
|
|
280
|
+
finally {
|
|
281
|
+
await miri[Symbol.asyncDispose]();
|
|
282
|
+
}
|
|
270
283
|
});
|
|
271
284
|
initProgram
|
|
272
285
|
.command('remove')
|
|
@@ -274,8 +287,12 @@ initProgram
|
|
|
274
287
|
.option('--no-exec', "Don' execute patch, just set as done")
|
|
275
288
|
.action(async (patch, opts) => {
|
|
276
289
|
const miri = await getMiri();
|
|
277
|
-
|
|
278
|
-
|
|
290
|
+
try {
|
|
291
|
+
await miri.remove('init', patch, Boolean(opts?.exec));
|
|
292
|
+
}
|
|
293
|
+
finally {
|
|
294
|
+
await miri[Symbol.asyncDispose]();
|
|
295
|
+
}
|
|
279
296
|
});
|
|
280
297
|
initProgram.command('status').action(() => status(false, 'init'));
|
|
281
298
|
const indexesProgram = program.command('indexes').description('Manage indexes');
|
|
@@ -285,8 +302,13 @@ indexesProgram
|
|
|
285
302
|
.option('-q --quiet', 'Show only changes', false)
|
|
286
303
|
.action(async (collection, { quiet }) => {
|
|
287
304
|
const miri = await getMiri();
|
|
288
|
-
|
|
289
|
-
|
|
305
|
+
let structure;
|
|
306
|
+
try {
|
|
307
|
+
structure = await miri.indexesDiff(collection);
|
|
308
|
+
}
|
|
309
|
+
finally {
|
|
310
|
+
await miri[Symbol.asyncDispose]();
|
|
311
|
+
}
|
|
290
312
|
for (const [collection, indexes] of Object.entries(structure)) {
|
|
291
313
|
let changes = false;
|
|
292
314
|
for (const [name, detail] of Object.entries(indexes)) {
|
|
@@ -317,8 +339,12 @@ indexesProgram
|
|
|
317
339
|
const indexSyncProgram = indexesProgram.command('sync');
|
|
318
340
|
indexSyncProgram.argument('[collection]', 'MongoDB Collection name', '').action(async (collection) => {
|
|
319
341
|
const miri = await getMiri();
|
|
320
|
-
|
|
321
|
-
|
|
342
|
+
try {
|
|
343
|
+
await syncIndexes(miri, collection);
|
|
344
|
+
}
|
|
345
|
+
finally {
|
|
346
|
+
await miri[Symbol.asyncDispose]();
|
|
347
|
+
}
|
|
322
348
|
});
|
|
323
349
|
const patchProgram = program.command('patch').description('Applies patch to database');
|
|
324
350
|
patchProgram
|
|
@@ -333,8 +359,12 @@ patchProgram
|
|
|
333
359
|
.option('--all', 'Re-apply all patches')
|
|
334
360
|
.action(async (opts) => {
|
|
335
361
|
const miri = await getMiri();
|
|
336
|
-
|
|
337
|
-
|
|
362
|
+
try {
|
|
363
|
+
await miri.sync(opts);
|
|
364
|
+
}
|
|
365
|
+
finally {
|
|
366
|
+
await miri[Symbol.asyncDispose]();
|
|
367
|
+
}
|
|
338
368
|
});
|
|
339
369
|
patchProgram
|
|
340
370
|
.command('apply')
|
|
@@ -343,8 +373,12 @@ patchProgram
|
|
|
343
373
|
.option('--no-exec', "Don' execute patch, just set as done")
|
|
344
374
|
.action(async (group, patch, opts) => {
|
|
345
375
|
const miri = await getMiri();
|
|
346
|
-
|
|
347
|
-
|
|
376
|
+
try {
|
|
377
|
+
await miri.applySingle(group, patch, Boolean(opts.exec));
|
|
378
|
+
}
|
|
379
|
+
finally {
|
|
380
|
+
await miri[Symbol.asyncDispose]();
|
|
381
|
+
}
|
|
348
382
|
});
|
|
349
383
|
patchProgram
|
|
350
384
|
.command('remove')
|
|
@@ -353,13 +387,31 @@ patchProgram
|
|
|
353
387
|
.option('--no-exec', "Don' execute patch, just set as done")
|
|
354
388
|
.action(async (group, patch, opts) => {
|
|
355
389
|
const miri = await getMiri();
|
|
356
|
-
|
|
357
|
-
|
|
390
|
+
try {
|
|
391
|
+
await miri.remove(group, patch, Boolean(opts.exec));
|
|
392
|
+
}
|
|
393
|
+
finally {
|
|
394
|
+
await miri[Symbol.asyncDispose]();
|
|
395
|
+
}
|
|
358
396
|
});
|
|
359
|
-
|
|
360
|
-
for (const eventName of ['unhandledRejection', 'rejectionHandled', 'uncaughtException']) {
|
|
397
|
+
for (const eventName of ['unhandledRejection', 'uncaughtException']) {
|
|
361
398
|
process.on(eventName, (error) => {
|
|
362
399
|
console.error(colors.red(`${eventName}:\n ${error.name}: ${error.message}`));
|
|
400
|
+
if (error?.stack) {
|
|
401
|
+
console.error(colors.gray(error.stack));
|
|
402
|
+
}
|
|
403
|
+
process.exit(1);
|
|
363
404
|
});
|
|
364
405
|
}
|
|
406
|
+
try {
|
|
407
|
+
await program.parseAsync();
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
const err = error;
|
|
411
|
+
console.error(colors.red(`${err.name}: ${err.message}`));
|
|
412
|
+
if (err.stack) {
|
|
413
|
+
console.error(colors.gray(err.stack));
|
|
414
|
+
}
|
|
415
|
+
process.exit(1);
|
|
416
|
+
}
|
|
365
417
|
//# sourceMappingURL=cli.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@13w/miri",
|
|
3
3
|
"description": "MongoDB patch manager",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.26",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18"
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"tunnel-ssh": "^5.2.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^25.
|
|
40
|
-
"mongodb-log-writer": "^2.5.
|
|
39
|
+
"@types/node": "^25.9.1",
|
|
40
|
+
"mongodb-log-writer": "^2.5.13",
|
|
41
41
|
"ts-node": "^10.9.2",
|
|
42
42
|
"typescript": "^6.0.3"
|
|
43
43
|
},
|