@gricha/perry 0.1.8 → 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.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  <p align="center">
8
8
  <a href="https://github.com/gricha/perry/actions/workflows/test.yml"><img src="https://github.com/gricha/perry/actions/workflows/test.yml/badge.svg" alt="Tests"></a>
9
- <a href="https://www.npmjs.com/package/@gricha/perry"><img src="https://badge.fury.io/js/@gricha%2Fperry.svg" alt="npm version"></a>
9
+ <a href="https://github.com/gricha/perry/releases"><img src="https://img.shields.io/github/v/release/gricha/perry" alt="Release"></a>
10
10
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
11
11
  </p>
12
12
 
@@ -29,7 +29,7 @@ Perry is designed to run on a machine within a **secure private network** such a
29
29
  ### Install
30
30
 
31
31
  ```bash
32
- npm install -g @gricha/perry
32
+ curl -fsSL https://raw.githubusercontent.com/gricha/perry/main/install.sh | bash
33
33
  ```
34
34
 
35
35
  ### Start Agent
@@ -1,5 +1,6 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import path from 'path';
3
+ import { homedir } from 'os';
3
4
  const MIME_TYPES = {
4
5
  '.html': 'text/html',
5
6
  '.js': 'application/javascript',
@@ -17,15 +18,23 @@ const MIME_TYPES = {
17
18
  '.eot': 'application/vnd.ms-fontobject',
18
19
  };
19
20
  function getWebDir() {
20
- const distWeb = path.join(__dirname, 'web');
21
- const rootDistWeb = path.resolve(__dirname, '../../dist/agent/web');
22
- try {
23
- require('fs').accessSync(path.join(distWeb, 'index.html'));
24
- return distWeb;
25
- }
26
- catch {
27
- return rootDistWeb;
21
+ const candidates = [
22
+ path.join(__dirname, 'web'),
23
+ path.resolve(__dirname, '../../dist/agent/web'),
24
+ path.join(path.dirname(process.execPath), 'web'),
25
+ path.join(path.dirname(process.argv[0]), 'web'),
26
+ path.join(homedir(), '.perry', 'web'),
27
+ ];
28
+ for (const dir of candidates) {
29
+ try {
30
+ require('fs').accessSync(path.join(dir, 'index.html'));
31
+ return dir;
32
+ }
33
+ catch {
34
+ continue;
35
+ }
28
36
  }
37
+ return candidates[0];
29
38
  }
30
39
  export async function serveStatic(_req, res, pathname) {
31
40
  const webDir = getWebDir();
@@ -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.8",
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": {