@gricha/perry 0.1.7 → 0.2.0

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.
@@ -1,7 +1,7 @@
1
1
  import { homedir } from 'os';
2
2
  import { join } from 'path';
3
3
  import { mkdir, readFile, writeFile } from 'fs/promises';
4
- const PACKAGE_NAME = '@gricha/perry';
4
+ const GITHUB_REPO = 'gricha/perry';
5
5
  const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24 hours
6
6
  async function getCacheDir() {
7
7
  const dir = join(homedir(), '.config', 'perry');
@@ -29,13 +29,18 @@ async function writeCache(cache) {
29
29
  }
30
30
  async function fetchLatestVersion() {
31
31
  try {
32
- const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {
32
+ const response = await fetch(`https://api.github.com/repos/${GITHUB_REPO}/releases/latest`, {
33
33
  signal: AbortSignal.timeout(3000),
34
+ headers: {
35
+ Accept: 'application/vnd.github.v3+json',
36
+ 'User-Agent': 'perry-update-checker',
37
+ },
34
38
  });
35
39
  if (!response.ok)
36
40
  return null;
37
41
  const data = (await response.json());
38
- return data.version || null;
42
+ const tag = data.tag_name || null;
43
+ return tag ? tag.replace(/^v/, '') : null;
39
44
  }
40
45
  catch {
41
46
  return null;
@@ -68,10 +73,10 @@ export async function checkForUpdates(currentVersion) {
68
73
  }
69
74
  if (latestVersion && compareVersions(currentVersion, latestVersion) > 0) {
70
75
  console.log('');
71
- console.log(`\x1b[33m╭─────────────────────────────────────────────────────────╮\x1b[0m`);
72
- console.log(`\x1b[33m│\x1b[0m Update available: \x1b[90m${currentVersion}\x1b[0m → \x1b[32m${latestVersion}\x1b[0m \x1b[33m│\x1b[0m`);
73
- console.log(`\x1b[33m│\x1b[0m Run \x1b[36mnpm install -g ${PACKAGE_NAME}\x1b[0m to update \x1b[33m│\x1b[0m`);
74
- console.log(`\x1b[33m╰─────────────────────────────────────────────────────────╯\x1b[0m`);
76
+ console.log(`\x1b[33m╭──────────────────────────────────────────────────────────────────────────────────╮\x1b[0m`);
77
+ console.log(`\x1b[33m│\x1b[0m Update available: \x1b[90m${currentVersion}\x1b[0m → \x1b[32m${latestVersion}\x1b[0m \x1b[33m│\x1b[0m`);
78
+ console.log(`\x1b[33m│\x1b[0m Run: \x1b[36mcurl -fsSL https://raw.githubusercontent.com/${GITHUB_REPO}/main/install.sh | bash\x1b[0m \x1b[33m│\x1b[0m`);
79
+ console.log(`\x1b[33m╰──────────────────────────────────────────────────────────────────────────────────╯\x1b[0m`);
75
80
  console.log('');
76
81
  }
77
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gricha/perry",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "description": "Self-contained CLI for spinning up Docker-in-Docker development environments with SSH and proxy helpers.",
5
5
  "type": "module",
6
6
  "bin": {