@13w/miri 1.1.15 → 1.1.17
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 +19 -15
- package/dist/evaluator.js +1 -2
- package/dist/miri.js +0 -1
- package/dist/mongodb.js +0 -1
- package/package.json +20 -20
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { readFileSync, realpathSync } from 'node:fs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
|
-
Error.stackTraceLimit = Infinity;
|
|
4
3
|
import { join } from 'node:path';
|
|
5
|
-
|
|
4
|
+
Error.stackTraceLimit = Infinity;
|
|
5
|
+
import colors from 'colors';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
7
|
import { Table } from 'console-table-printer';
|
|
8
|
-
import colors from 'colors';
|
|
9
|
-
import { createTunnel } from 'tunnel-ssh';
|
|
10
8
|
import SSHConfig from 'ssh-config';
|
|
11
|
-
import
|
|
9
|
+
import { createTunnel } from 'tunnel-ssh';
|
|
12
10
|
import Miri, { IndexStatus, PatchStatus } from './miri.js';
|
|
11
|
+
import connection from './mongodb.js';
|
|
13
12
|
const pkg = await readFile(join(import.meta.dirname, '../package.json'), 'utf-8').then((content) => JSON.parse(content));
|
|
14
13
|
const mirirc = await readFile(join(process.cwd(), '.mirirc'), 'utf-8').then((content) => JSON.parse(content), () => ({}));
|
|
15
14
|
const { SSH_AUTH_SOCK, HOME } = process.env;
|
|
@@ -41,6 +40,7 @@ const askPassword = async (message = 'Password: ') => {
|
|
|
41
40
|
// Ctrl C
|
|
42
41
|
process.stdin.off('data', readPass);
|
|
43
42
|
reject(new Error('Cancelled'));
|
|
43
|
+
return;
|
|
44
44
|
default:
|
|
45
45
|
// More passsword characters
|
|
46
46
|
password += str;
|
|
@@ -56,12 +56,13 @@ program.version(pkg.version);
|
|
|
56
56
|
program.option('-e --env <environment>', 'Environment name from .mirirc', 'default');
|
|
57
57
|
program.option('-m --migrations <folder>', `Folder with migrations (default: "${process.cwd(), join(process.cwd(), 'migrations')}")`);
|
|
58
58
|
program.option('-d --db <mongo-uri>', 'MongoDB Connection URI (default: "mongodb://localhost:27017/test")');
|
|
59
|
+
program.option('--no-direct-connection', 'Disable direct connection', true);
|
|
59
60
|
program.option('--ssh-profile <profile>', 'Connect via SSH using profile');
|
|
60
61
|
program.option('--ssh-host <host>', 'Connect via SSH proxy Host');
|
|
61
62
|
program.option('--ssh-port <port>', 'Connect via SSH proxy Port');
|
|
62
63
|
program.option('--ssh-user <user>', 'Connect via SSH proxy User');
|
|
63
64
|
program.option('--ssh-key <path/to/key>', 'Connect via SSH proxy IdentityKey');
|
|
64
|
-
program.option('--ssh-ask-pass', 'Ask for the private key password'
|
|
65
|
+
program.option('--ssh-ask-pass', 'Ask for the private key password');
|
|
65
66
|
let configCache;
|
|
66
67
|
const getConfig = (programOpts) => {
|
|
67
68
|
if (configCache) {
|
|
@@ -84,19 +85,22 @@ const getConfig = (programOpts) => {
|
|
|
84
85
|
};
|
|
85
86
|
const createSSHTunnel = async (opts) => {
|
|
86
87
|
const config = getConfig(opts);
|
|
87
|
-
|
|
88
|
-
if (config.sshKey && config.sshAskPass) {
|
|
89
|
-
passphrase = await askPassword();
|
|
90
|
-
}
|
|
88
|
+
const passphrase = config.sshKey && config.sshAskPass ? await askPassword() : void 0;
|
|
91
89
|
const sshOptions = {
|
|
92
90
|
host: config.sshHost,
|
|
93
91
|
port: Number(config.sshPort ?? 22),
|
|
94
92
|
username: config.sshUser,
|
|
95
|
-
// agent: SSH_AUTH_SOCK,
|
|
96
|
-
privateKey: config.sshKey ? readFileSync(realpathSync(config.sshKey)) : void 0,
|
|
97
|
-
passphrase,
|
|
98
93
|
};
|
|
99
|
-
|
|
94
|
+
if (config.sshKey) {
|
|
95
|
+
sshOptions.privateKey = readFileSync(realpathSync(config.sshKey));
|
|
96
|
+
if (passphrase) {
|
|
97
|
+
sshOptions.passphrase = passphrase;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (SSH_AUTH_SOCK) {
|
|
101
|
+
sshOptions.agent = SSH_AUTH_SOCK;
|
|
102
|
+
}
|
|
103
|
+
// console.dir([config, sshOptions])
|
|
100
104
|
const dst = new URL(config.db);
|
|
101
105
|
const forwardOptions = {
|
|
102
106
|
dstPort: Number(dst.port ?? 27017),
|
|
@@ -112,7 +116,7 @@ const getMiri = async () => {
|
|
|
112
116
|
const config = getConfig(program.opts());
|
|
113
117
|
const db = config.sshHost ? await createSSHTunnel(config) : config.db;
|
|
114
118
|
const dbUri = new URL(db);
|
|
115
|
-
dbUri.searchParams.append('directConnection',
|
|
119
|
+
dbUri.searchParams.append('directConnection', String(config.directConnection ?? true));
|
|
116
120
|
dbUri.searchParams.append('appName', `miri+v${pkg.version}`);
|
|
117
121
|
const client = await connection(dbUri.toString());
|
|
118
122
|
return new Miri(client, {
|
package/dist/evaluator.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import { EventEmitter } from 'node:events';
|
|
3
2
|
import { createContext, runInContext, SourceTextModule, SyntheticModule } from 'node:vm';
|
|
4
3
|
import { inspect } from 'node:util';
|
|
@@ -46,7 +45,7 @@ export async function evaluateMongo(client, code, filename = '[no file]') {
|
|
|
46
45
|
onLoad() {
|
|
47
46
|
throw new Error('Load isn\'t supported');
|
|
48
47
|
},
|
|
49
|
-
|
|
48
|
+
onExit() {
|
|
50
49
|
throw new Error('Exit isn\'t supported');
|
|
51
50
|
},
|
|
52
51
|
});
|
package/dist/miri.js
CHANGED
package/dist/mongodb.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@13w/miri",
|
|
3
3
|
"description": "MongoDB patch manager",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.17",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": "
|
|
7
|
+
"node": "v22"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
10
10
|
"MongoDB",
|
|
@@ -24,30 +24,30 @@
|
|
|
24
24
|
],
|
|
25
25
|
"main": "bin/miri",
|
|
26
26
|
"types": "types/miri.d.ts",
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "tsc -p tsconfig.json",
|
|
29
|
-
"lint": "eslint src/ --ext .ts --quiet",
|
|
30
|
-
"prepublish": "pnpm run build"
|
|
31
|
-
},
|
|
32
27
|
"dependencies": {
|
|
33
|
-
"@mongosh/service-provider-server": "^2.
|
|
34
|
-
"@mongosh/shell-api": "^2.
|
|
35
|
-
"@mongosh/shell-evaluator": "^2.
|
|
28
|
+
"@mongosh/service-provider-server": "^2.3.1",
|
|
29
|
+
"@mongosh/shell-api": "^2.3.1",
|
|
30
|
+
"@mongosh/shell-evaluator": "^2.3.1",
|
|
36
31
|
"colors": "^1.4.0",
|
|
37
32
|
"commander": "^12.1.0",
|
|
38
33
|
"console-table-printer": "^2.12.1",
|
|
39
|
-
"mongodb": "^6.
|
|
40
|
-
"ssh-config": "^
|
|
34
|
+
"mongodb": "^6.9.0",
|
|
35
|
+
"ssh-config": "^5.0.0",
|
|
41
36
|
"tunnel-ssh": "^5.1.2"
|
|
42
37
|
},
|
|
43
38
|
"devDependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"eslint-plugin-deprecation": "^2.0.0",
|
|
39
|
+
"@eslint/js": "^9.10.0",
|
|
40
|
+
"@types/node": "^22.5.5",
|
|
41
|
+
"eslint": "^9.10.0",
|
|
42
|
+
"mongodb-log-writer": "^1.4.2",
|
|
49
43
|
"ts-node": "^10.9.2",
|
|
50
|
-
"typescript": "^5.
|
|
44
|
+
"typescript": "^5.6.2",
|
|
45
|
+
"typescript-eslint": "^8.5.0"
|
|
51
46
|
},
|
|
52
|
-
"license": "MIT"
|
|
53
|
-
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.json",
|
|
50
|
+
"lint": "eslint --quiet src/",
|
|
51
|
+
"prepublish": "pnpm run build"
|
|
52
|
+
}
|
|
53
|
+
}
|