mpx-api 1.2.0 → 1.2.2
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/LICENSE +19 -9
- package/bin/mpx-api.js +73 -0
- package/package.json +2 -2
- package/src/schema.js +12 -0
- package/src/update.js +72 -0
package/LICENSE
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
Mesaplex Dual License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2026 Mesaplex
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
5
|
+
This software is available under two licensing options:
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
1. FREE TIER (Personal Use)
|
|
8
|
+
- Limited daily usage
|
|
9
|
+
- Basic features only
|
|
10
|
+
- Personal and non-commercial use only
|
|
11
|
+
|
|
12
|
+
Permission is granted to use this software for personal, non-commercial
|
|
13
|
+
purposes subject to the usage limits described in the documentation.
|
|
14
|
+
|
|
15
|
+
2. PRO LICENSE (Commercial Use)
|
|
16
|
+
- Unlimited usage
|
|
17
|
+
- All features unlocked
|
|
18
|
+
- JSON/CSV export
|
|
19
|
+
- CI/CD integration
|
|
20
|
+
- Commercial use allowed
|
|
21
|
+
- Priority support
|
|
22
|
+
|
|
23
|
+
To obtain a Pro license, visit: https://mesaplex.com
|
|
14
24
|
|
|
15
25
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
26
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
package/bin/mpx-api.js
CHANGED
|
@@ -63,6 +63,79 @@ registerHistoryCommand(program);
|
|
|
63
63
|
registerLoadCommand(program);
|
|
64
64
|
registerDocsCommand(program);
|
|
65
65
|
|
|
66
|
+
// Update subcommand
|
|
67
|
+
program
|
|
68
|
+
.command('update')
|
|
69
|
+
.description('Check for updates and optionally install the latest version')
|
|
70
|
+
.option('--check', 'Only check for updates (do not install)')
|
|
71
|
+
.action(async (options, cmd) => {
|
|
72
|
+
const { checkForUpdate, performUpdate } = await import('../src/update.js');
|
|
73
|
+
const chalk = (await import('chalk')).default;
|
|
74
|
+
const jsonMode = cmd.parent?.opts()?.output === 'json';
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const info = checkForUpdate();
|
|
78
|
+
|
|
79
|
+
if (jsonMode) {
|
|
80
|
+
const output = {
|
|
81
|
+
current: info.current,
|
|
82
|
+
latest: info.latest,
|
|
83
|
+
updateAvailable: info.updateAvailable,
|
|
84
|
+
isGlobal: info.isGlobal
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
if (!options.check && info.updateAvailable) {
|
|
88
|
+
try {
|
|
89
|
+
const result = performUpdate(info.isGlobal);
|
|
90
|
+
output.updated = true;
|
|
91
|
+
output.newVersion = result.version;
|
|
92
|
+
} catch (err) {
|
|
93
|
+
output.updated = false;
|
|
94
|
+
output.error = err.message;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
console.log(JSON.stringify(output, null, 2));
|
|
99
|
+
process.exit(0);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Human-readable output
|
|
104
|
+
if (!info.updateAvailable) {
|
|
105
|
+
console.log('');
|
|
106
|
+
console.log(chalk.green.bold(`✓ mpx-api v${info.current} is up to date`));
|
|
107
|
+
console.log('');
|
|
108
|
+
process.exit(0);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log('');
|
|
113
|
+
console.log(chalk.yellow.bold(`⬆ Update available: v${info.current} → v${info.latest}`));
|
|
114
|
+
|
|
115
|
+
if (options.check) {
|
|
116
|
+
console.log(chalk.gray(`Run ${chalk.cyan('mpx-api update')} to install`));
|
|
117
|
+
console.log('');
|
|
118
|
+
process.exit(0);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
console.log(chalk.gray(`Installing v${info.latest}${info.isGlobal ? ' (global)' : ''}...`));
|
|
123
|
+
|
|
124
|
+
const result = performUpdate(info.isGlobal);
|
|
125
|
+
console.log(chalk.green.bold(`✓ Updated to v${result.version}`));
|
|
126
|
+
console.log('');
|
|
127
|
+
process.exit(0);
|
|
128
|
+
} catch (err) {
|
|
129
|
+
if (jsonMode) {
|
|
130
|
+
console.log(JSON.stringify({ error: err.message, code: 'ERR_UPDATE' }, null, 2));
|
|
131
|
+
} else {
|
|
132
|
+
console.error(chalk.red.bold('\n❌ Update check failed:'), err.message);
|
|
133
|
+
console.error('');
|
|
134
|
+
}
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
66
139
|
// MCP subcommand
|
|
67
140
|
program
|
|
68
141
|
.command('mcp')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mpx-api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Developer-first API testing, mocking, and documentation CLI with AI-native features (JSON output, MCP server)",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"automation"
|
|
24
24
|
],
|
|
25
25
|
"author": "Mesaplex <support@mesaplex.com>",
|
|
26
|
-
"license": "
|
|
26
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
29
|
"url": "git+https://github.com/mesaplexdev/mpx-api.git"
|
package/src/schema.js
CHANGED
|
@@ -253,6 +253,18 @@ export function getSchema() {
|
|
|
253
253
|
examples: [
|
|
254
254
|
{ command: 'mpx-api mcp', description: 'Start MCP stdio server' }
|
|
255
255
|
]
|
|
256
|
+
},
|
|
257
|
+
update: {
|
|
258
|
+
description: 'Check for updates and optionally install the latest version',
|
|
259
|
+
usage: 'mpx-api update [--check] [-o json]',
|
|
260
|
+
flags: {
|
|
261
|
+
'--check': { description: 'Only check for updates (do not install)', default: false }
|
|
262
|
+
},
|
|
263
|
+
examples: [
|
|
264
|
+
{ command: 'mpx-api update', description: 'Check and install updates' },
|
|
265
|
+
{ command: 'mpx-api update --check', description: 'Just check for updates' },
|
|
266
|
+
{ command: 'mpx-api update --check -o json', description: 'Check for updates (JSON output)' }
|
|
267
|
+
]
|
|
256
268
|
}
|
|
257
269
|
},
|
|
258
270
|
globalFlags: {
|
package/src/update.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update Command
|
|
3
|
+
*
|
|
4
|
+
* Checks npm for the latest version of mpx-api and offers to update.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
import { readFileSync } from 'fs';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { dirname, join } from 'path';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'));
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Check npm registry for latest version
|
|
18
|
+
* @returns {object} { current, latest, updateAvailable, isGlobal }
|
|
19
|
+
*/
|
|
20
|
+
export function checkForUpdate() {
|
|
21
|
+
const current = pkg.version;
|
|
22
|
+
|
|
23
|
+
let latest;
|
|
24
|
+
try {
|
|
25
|
+
latest = execSync('npm view mpx-api version', { encoding: 'utf8', timeout: 10000 }).trim();
|
|
26
|
+
} catch (err) {
|
|
27
|
+
throw new Error('Failed to check npm registry: ' + (err.message || 'unknown error'));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const updateAvailable = latest !== current && compareVersions(latest, current) > 0;
|
|
31
|
+
|
|
32
|
+
// Detect if installed globally
|
|
33
|
+
let isGlobal = false;
|
|
34
|
+
try {
|
|
35
|
+
const globalDir = execSync('npm root -g', { encoding: 'utf8', timeout: 5000 }).trim();
|
|
36
|
+
isGlobal = __dirname.startsWith(globalDir) || process.argv[1]?.includes('node_modules/.bin');
|
|
37
|
+
} catch {
|
|
38
|
+
// Can't determine, assume local
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return { current, latest, updateAvailable, isGlobal };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Perform the update
|
|
46
|
+
* @param {boolean} isGlobal - Install globally
|
|
47
|
+
* @returns {object} { success, version }
|
|
48
|
+
*/
|
|
49
|
+
export function performUpdate(isGlobal) {
|
|
50
|
+
const cmd = isGlobal ? 'npm install -g mpx-api@latest' : 'npm install mpx-api@latest';
|
|
51
|
+
try {
|
|
52
|
+
execSync(cmd, { encoding: 'utf8', timeout: 60000, stdio: 'pipe' });
|
|
53
|
+
// Verify
|
|
54
|
+
const newVersion = execSync('npm view mpx-api version', { encoding: 'utf8', timeout: 10000 }).trim();
|
|
55
|
+
return { success: true, version: newVersion };
|
|
56
|
+
} catch (err) {
|
|
57
|
+
throw new Error('Update failed: ' + (err.message || 'unknown error'));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Compare semver strings. Returns >0 if a > b, <0 if a < b, 0 if equal.
|
|
63
|
+
*/
|
|
64
|
+
export function compareVersions(a, b) {
|
|
65
|
+
const pa = a.split('.').map(Number);
|
|
66
|
+
const pb = b.split('.').map(Number);
|
|
67
|
+
for (let i = 0; i < 3; i++) {
|
|
68
|
+
if ((pa[i] || 0) > (pb[i] || 0)) return 1;
|
|
69
|
+
if ((pa[i] || 0) < (pb[i] || 0)) return -1;
|
|
70
|
+
}
|
|
71
|
+
return 0;
|
|
72
|
+
}
|