mailos 0.1.43 → 0.1.45

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.
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailos",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "description": "Command-line email client with AI integration and support for multiple providers",
5
5
  "keywords": [
6
6
  "email",
@@ -2,15 +2,8 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const { execSync } = require('child_process');
6
- const fetch = require('node-fetch');
7
- const tar = require('tar');
8
- const rimraf = require('rimraf');
9
5
 
10
6
  const BINARY_NAME = 'mailos';
11
- const GITHUB_REPO = 'emailos/mailos';
12
- const VERSION = require('../package.json').version;
13
- const USE_LOCAL_BUILD = process.env.MAILOS_BUILD_LOCAL === 'true';
14
7
 
15
8
  // Platform mapping
16
9
  const PLATFORM_MAPPING = {
@@ -19,152 +12,51 @@ const PLATFORM_MAPPING = {
19
12
  'linux-x64': 'linux-amd64',
20
13
  'linux-arm64': 'linux-arm64',
21
14
  'win32-x64': 'windows-amd64',
22
- 'win32-arm64': 'windows-arm64'
15
+ 'win32-arm64': 'windows-amd64' // Fallback to x64 for Windows ARM
23
16
  };
24
17
 
25
- async function getDownloadUrl() {
26
- const platform = process.platform;
27
- const arch = process.arch;
28
- const platformKey = `${platform}-${arch}`;
29
-
30
- const goPlatform = PLATFORM_MAPPING[platformKey];
31
- if (!goPlatform) {
32
- throw new Error(`Unsupported platform: ${platformKey}`);
33
- }
34
-
35
- // Check if we should build locally
36
- if (USE_LOCAL_BUILD) {
37
- return { goPlatform, needsBuild: true };
38
- }
39
-
40
- // Try to get release URL
18
+ function install() {
41
19
  try {
42
- const releaseUrl = `https://api.github.com/repos/${GITHUB_REPO}/releases/tags/v${VERSION}`;
43
- const response = await fetch(releaseUrl);
20
+ const platform = process.platform;
21
+ const arch = process.arch;
22
+ const platformKey = `${platform}-${arch}`;
44
23
 
45
- if (response.ok) {
46
- const release = await response.json();
47
- const assetName = `mailos-${goPlatform}.tar.gz`;
48
- const asset = release.assets.find(a => a.name === assetName);
49
-
50
- if (asset) {
51
- return {
52
- goPlatform,
53
- needsBuild: false,
54
- downloadUrl: asset.browser_download_url
55
- };
56
- }
24
+ const goPlatform = PLATFORM_MAPPING[platformKey];
25
+ if (!goPlatform) {
26
+ throw new Error(`Unsupported platform: ${platformKey}`);
57
27
  }
58
- } catch (error) {
59
- console.warn('Could not fetch release info, will build locally');
60
- }
61
-
62
- // Fall back to local build
63
- return { goPlatform, needsBuild: true };
64
- }
65
-
66
- async function downloadBinary(url, dest) {
67
- console.log(`Downloading ${BINARY_NAME} from ${url}...`);
68
-
69
- const response = await fetch(url);
70
- if (!response.ok) {
71
- throw new Error(`Failed to download: ${response.statusText}`);
72
- }
73
-
74
- const buffer = await response.buffer();
75
- fs.writeFileSync(dest, buffer);
76
-
77
- if (process.platform !== 'win32') {
78
- fs.chmodSync(dest, '755');
79
- }
80
-
81
- console.log(`Downloaded ${BINARY_NAME} successfully!`);
82
- }
83
-
84
- async function buildBinary() {
85
- console.log(`Building ${BINARY_NAME} from source...`);
86
-
87
- const binDir = path.join(__dirname, '..', 'bin');
88
- const binPath = path.join(binDir, process.platform === 'win32' ? `${BINARY_NAME}.exe` : BINARY_NAME);
89
-
90
- // Ensure bin directory exists
91
- if (!fs.existsSync(binDir)) {
92
- fs.mkdirSync(binDir, { recursive: true });
93
- }
94
-
95
- // Build the Go binary
96
- const goPath = path.join(__dirname, '..', '..', 'cmd', 'mailos', 'main.go');
97
- const goBuildCmd = `go build -o "${binPath}" "${goPath}"`;
98
-
99
- try {
100
- console.log('Running go build...');
101
- execSync(goBuildCmd, {
102
- stdio: 'inherit',
103
- cwd: path.join(__dirname, '..', '..')
104
- });
105
- console.log(`Built ${BINARY_NAME} successfully!`);
106
- } catch (error) {
107
- console.error('Failed to build from source. Make sure Go is installed.');
108
- throw error;
109
- }
110
- }
111
-
112
- async function downloadAndExtract(url, destDir) {
113
- console.log(`Downloading from ${url}...`);
114
-
115
- const response = await fetch(url);
116
- if (!response.ok) {
117
- throw new Error(`Failed to download: ${response.statusText}`);
118
- }
119
-
120
- const buffer = await response.buffer();
121
-
122
- // Extract tar.gz
123
- await tar.x({
124
- file: buffer,
125
- cwd: destDir,
126
- strip: 0
127
- });
128
-
129
- console.log('Extracted successfully!');
130
- }
131
-
132
- async function install() {
133
- try {
134
- const { goPlatform, needsBuild, downloadUrl } = await getDownloadUrl();
135
28
 
136
- const binDir = path.join(__dirname, '..', 'bin');
137
- if (!fs.existsSync(binDir)) {
138
- fs.mkdirSync(binDir, { recursive: true });
29
+ console.log(`Installing ${BINARY_NAME} for ${platformKey} (${goPlatform})`);
30
+
31
+ // Determine source and target binary paths
32
+ const isWindows = platform === 'win32';
33
+ const sourceExt = isWindows ? '.exe' : '';
34
+ const sourceBinary = path.join(__dirname, '..', 'bin', `${BINARY_NAME}-${goPlatform}${sourceExt}`);
35
+ const targetBinary = path.join(__dirname, '..', 'bin', `${BINARY_NAME}${sourceExt}`);
36
+
37
+ // Check if source binary exists
38
+ if (!fs.existsSync(sourceBinary)) {
39
+ throw new Error(`Binary not found for platform ${goPlatform}: ${sourceBinary}`);
139
40
  }
140
41
 
141
- if (needsBuild) {
142
- // Check if Go is installed
143
- try {
144
- execSync('go version', { stdio: 'ignore' });
145
- } catch (error) {
146
- console.error('Go is not installed. Please install Go to build mailos.');
147
- console.error('Visit: https://golang.org/dl/');
148
- process.exit(1);
149
- }
150
-
151
- await buildBinary();
152
- } else {
153
- // Download pre-built binary
154
- await downloadAndExtract(downloadUrl, binDir);
155
-
156
- // Make binary executable
157
- const binPath = path.join(binDir, process.platform === 'win32' ? `${BINARY_NAME}.exe` : BINARY_NAME);
158
- if (process.platform !== 'win32') {
159
- fs.chmodSync(binPath, '755');
160
- }
42
+ // Copy platform-specific binary to generic name
43
+ console.log(`Copying ${sourceBinary} to ${targetBinary}`);
44
+ fs.copyFileSync(sourceBinary, targetBinary);
45
+
46
+ // Make executable on Unix systems
47
+ if (!isWindows) {
48
+ fs.chmodSync(targetBinary, '755');
161
49
  }
162
50
 
163
- console.log('\n✓ mailos installed successfully!');
51
+ console.log(`✓ ${BINARY_NAME} installed successfully!`);
164
52
  console.log('Run "mailos help" to get started.');
165
53
 
166
54
  } catch (error) {
167
55
  console.error('Installation failed:', error.message);
56
+ console.error('\nTroubleshooting:');
57
+ console.error('- Check if your platform is supported');
58
+ console.error('- Try reinstalling the package');
59
+ console.error('- Report issues at: https://github.com/anduimagui/emailos-cli/issues');
168
60
  process.exit(1);
169
61
  }
170
62
  }
@@ -2,17 +2,20 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const rimraf = require('rimraf');
6
5
 
7
- const binDir = path.join(__dirname, '..', 'bin');
6
+ const binPath = path.join(__dirname, '..', 'bin', 'mailos');
7
+ const binPathWin = path.join(__dirname, '..', 'bin', 'mailos.exe');
8
8
 
9
9
  console.log('Cleaning up mailos binary...');
10
10
 
11
11
  try {
12
- if (fs.existsSync(binDir)) {
13
- rimraf.sync(binDir);
14
- console.log('✓ Cleanup complete');
12
+ if (fs.existsSync(binPath)) {
13
+ fs.unlinkSync(binPath);
15
14
  }
15
+ if (fs.existsSync(binPathWin)) {
16
+ fs.unlinkSync(binPathWin);
17
+ }
18
+ console.log('✓ Cleanup complete');
16
19
  } catch (error) {
17
20
  console.error('Cleanup failed:', error.message);
18
21
  }