@series-inc/stowkit-cli 0.1.21 → 0.1.22
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 +24 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import * as fs from 'node:fs';
|
|
2
3
|
import * as path from 'node:path';
|
|
3
4
|
import { existsSync } from 'node:fs';
|
|
4
5
|
import { fileURLToPath } from 'node:url';
|
|
@@ -10,6 +11,29 @@ import { createMaterial } from './create-material.js';
|
|
|
10
11
|
import { renameAsset, moveAsset, deleteAsset, setStringId } from './asset-commands.js';
|
|
11
12
|
const args = process.argv.slice(2);
|
|
12
13
|
const thisDir = path.dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
function checkForUpdate() {
|
|
15
|
+
try {
|
|
16
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(thisDir, '../package.json'), 'utf-8'));
|
|
17
|
+
const localVersion = pkg.version;
|
|
18
|
+
const controller = new AbortController();
|
|
19
|
+
const timeout = setTimeout(() => controller.abort(), 3000);
|
|
20
|
+
fetch('https://registry.npmjs.org/@series-inc/stowkit-cli/latest', { signal: controller.signal })
|
|
21
|
+
.then(res => res.json())
|
|
22
|
+
.then((data) => {
|
|
23
|
+
clearTimeout(timeout);
|
|
24
|
+
const latest = data.version;
|
|
25
|
+
if (latest && latest !== localVersion) {
|
|
26
|
+
console.log(`\n Update available: ${localVersion} → ${latest}`);
|
|
27
|
+
console.log(` Run: npm install -g @series-inc/stowkit-cli\n`);
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
.catch(() => { clearTimeout(timeout); });
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Can't read package.json or fetch — skip silently
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
checkForUpdate();
|
|
13
37
|
function printUsage() {
|
|
14
38
|
console.log(`
|
|
15
39
|
Usage:
|