olly-molly 0.1.8 → 0.1.10

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.
Files changed (2) hide show
  1. package/bin/cli.js +28 -45
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -6,25 +6,28 @@ const fs = require('fs');
6
6
  const os = require('os');
7
7
  const https = require('https');
8
8
 
9
+ const PACKAGE_NAME = 'olly-molly';
9
10
  const REPO = 'ruucm/olly-molly';
10
11
  const APP_DIR = path.join(os.homedir(), '.olly-molly');
11
12
  const DB_DIR = path.join(APP_DIR, 'db');
12
13
  const TARBALL_URL = `https://github.com/${REPO}/archive/refs/heads/main.tar.gz`;
13
- const VERSION_URL = `https://raw.githubusercontent.com/${REPO}/main/package.json`;
14
14
 
15
15
  console.log('\nšŸ™ Olly Molly\n');
16
16
 
17
- function fetchJSON(url) {
18
- return new Promise((resolve, reject) => {
19
- const get = (u) => {
20
- https.get(u, (res) => {
21
- if (res.statusCode === 302 || res.statusCode === 301) return get(res.headers.location);
22
- let data = '';
23
- res.on('data', c => data += c);
24
- res.on('end', () => { try { resolve(JSON.parse(data)); } catch { reject(); } });
25
- }).on('error', reject);
26
- };
27
- get(url);
17
+ // Get latest version from npm registry
18
+ function getNpmVersion() {
19
+ return new Promise((resolve) => {
20
+ https.get(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, (res) => {
21
+ let data = '';
22
+ res.on('data', c => data += c);
23
+ res.on('end', () => {
24
+ try {
25
+ resolve(JSON.parse(data).version);
26
+ } catch {
27
+ resolve(null);
28
+ }
29
+ });
30
+ }).on('error', () => resolve(null));
28
31
  });
29
32
  }
30
33
 
@@ -52,12 +55,10 @@ function download(url, destDir) {
52
55
 
53
56
  function getLocalVersion() {
54
57
  try {
55
- const pkg = JSON.parse(fs.readFileSync(path.join(APP_DIR, 'package.json'), 'utf8'));
56
- return pkg.version;
58
+ return JSON.parse(fs.readFileSync(path.join(APP_DIR, 'package.json'), 'utf8')).version;
57
59
  } catch { return null; }
58
60
  }
59
61
 
60
- // Backup and restore user's database
61
62
  function backupDB() {
62
63
  const backupDir = path.join(os.tmpdir(), 'olly-molly-db-backup');
63
64
  if (fs.existsSync(DB_DIR)) {
@@ -70,10 +71,8 @@ function backupDB() {
70
71
  function restoreDB(backupDir) {
71
72
  if (backupDir && fs.existsSync(backupDir)) {
72
73
  fs.mkdirSync(DB_DIR, { recursive: true });
73
- // Only restore sqlite files, not schema files
74
- const files = fs.readdirSync(backupDir);
75
- for (const file of files) {
76
- if (file.endsWith('.sqlite') || file.endsWith('.sqlite-shm') || file.endsWith('.sqlite-wal')) {
74
+ for (const file of fs.readdirSync(backupDir)) {
75
+ if (file.includes('.sqlite')) {
77
76
  fs.copyFileSync(path.join(backupDir, file), path.join(DB_DIR, file));
78
77
  }
79
78
  }
@@ -85,54 +84,38 @@ async function main() {
85
84
  let needsInstall = false;
86
85
  let needsBuild = false;
87
86
 
88
- // Check for updates
89
87
  const localVersion = getLocalVersion();
90
- let remoteVersion = null;
91
-
92
- try {
93
- remoteVersion = (await fetchJSON(VERSION_URL)).version;
94
- } catch {
95
- // Offline - continue with local
96
- }
88
+ const npmVersion = await getNpmVersion();
97
89
 
98
- // Update if version changed (preserve DB!)
99
- if (localVersion && remoteVersion && localVersion !== remoteVersion) {
100
- console.log(`šŸ”„ Updating ${localVersion} → ${remoteVersion}\n`);
101
-
102
- // Backup DB before update
90
+ // Update if npm version is newer
91
+ if (localVersion && npmVersion && localVersion !== npmVersion) {
92
+ console.log(`šŸ”„ Updating ${localVersion} → ${npmVersion}\n`);
103
93
  const dbBackup = backupDB();
104
-
105
- // Remove app (but DB is backed up)
106
94
  fs.rmSync(APP_DIR, { recursive: true, force: true });
107
-
108
- // Download new version
109
95
  console.log('šŸ“„ Downloading...');
110
96
  await download(TARBALL_URL, APP_DIR);
111
- console.log('āœ… Done\n');
112
-
113
- // Restore DB
97
+ console.log('āœ… Downloaded\n');
114
98
  restoreDB(dbBackup);
115
-
116
99
  needsInstall = true;
117
100
  needsBuild = true;
118
101
  }
119
102
 
120
- // First time download
103
+ // First time
121
104
  if (!fs.existsSync(APP_DIR)) {
122
105
  console.log('šŸ“„ Downloading...');
123
106
  await download(TARBALL_URL, APP_DIR);
124
- console.log('āœ… Done\n');
107
+ console.log('āœ… Downloaded\n');
125
108
  needsInstall = true;
126
109
  needsBuild = true;
127
110
  }
128
111
 
129
- // Install if needed
112
+ // Install
130
113
  if (needsInstall || !fs.existsSync(path.join(APP_DIR, 'node_modules'))) {
131
- console.log('šŸ“¦ Installing dependencies...\n');
114
+ console.log('šŸ“¦ Installing...\n');
132
115
  execSync('npm install --omit=dev', { cwd: APP_DIR, stdio: 'inherit' });
133
116
  }
134
117
 
135
- // Build if needed
118
+ // Build
136
119
  if (needsBuild || !fs.existsSync(path.join(APP_DIR, '.next'))) {
137
120
  console.log('\nšŸ”Ø Building...\n');
138
121
  execSync('npm run build', { cwd: APP_DIR, stdio: 'inherit' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "olly-molly",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Your AI Development Team, Running Locally - Manage AI agents (PM, Frontend, Backend, QA) from a beautiful kanban board",
5
5
  "keywords": [
6
6
  "ai",