@dinoxx/dinox-cli 1.0.8 → 1.0.9
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 +2 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.js +29 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ import { registerInfoCommand } from './commands/info/index.js';
|
|
|
6
6
|
import { registerNoteCommands } from './commands/notes/index.js';
|
|
7
7
|
import { registerPromptCommands } from './commands/prompt/index.js';
|
|
8
8
|
import { registerSyncCommand } from './commands/sync.js';
|
|
9
|
+
import { registerUpdateCommand } from './commands/update.js';
|
|
9
10
|
import { registerTagsCommand } from './commands/tags/index.js';
|
|
10
11
|
import { getPackageVersion } from './utils/version.js';
|
|
11
12
|
export function createCli() {
|
|
@@ -25,6 +26,7 @@ export function createCli() {
|
|
|
25
26
|
registerConfigCommands(program);
|
|
26
27
|
registerInfoCommand(program);
|
|
27
28
|
registerSyncCommand(program);
|
|
29
|
+
registerUpdateCommand(program);
|
|
28
30
|
registerPromptCommands(program);
|
|
29
31
|
registerTagsCommand(program);
|
|
30
32
|
registerNoteCommands(program);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { getPackageVersion } from '../utils/version.js';
|
|
3
|
+
const PACKAGE_NAME = '@dinoxx/dinox-cli';
|
|
4
|
+
function runNpmUpdate() {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
7
|
+
const child = spawn(npm, ['update', '-g', PACKAGE_NAME], { stdio: 'inherit' });
|
|
8
|
+
child.on('close', (code) => {
|
|
9
|
+
if (code === 0) {
|
|
10
|
+
resolve();
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
reject(new Error(`npm exited with code ${code}`));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
child.on('error', reject);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function registerUpdateCommand(program) {
|
|
20
|
+
program
|
|
21
|
+
.command('update')
|
|
22
|
+
.description(`Update ${PACKAGE_NAME} to the latest version`)
|
|
23
|
+
.action(async () => {
|
|
24
|
+
console.log(`current version: ${getPackageVersion()}`);
|
|
25
|
+
console.log(`updating ${PACKAGE_NAME}...`);
|
|
26
|
+
await runNpmUpdate();
|
|
27
|
+
console.log('done');
|
|
28
|
+
});
|
|
29
|
+
}
|