mailos 0.1.6

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 ADDED
@@ -0,0 +1,122 @@
1
+ # mailos
2
+
3
+ EmailOS - A standardized email client CLI with support for multiple providers
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g mailos
9
+ ```
10
+
11
+ ## Requirements
12
+
13
+ - Node.js 14.0.0 or higher
14
+ - Go 1.21 or higher (for building from source)
15
+
16
+ ## Quick Start
17
+
18
+ 1. **Setup your email account:**
19
+ ```bash
20
+ mailos setup
21
+ ```
22
+
23
+ 2. **Send an email:**
24
+ ```bash
25
+ mailos send -t recipient@example.com -s "Hello" -b "This is a test email"
26
+ ```
27
+
28
+ 3. **Read emails:**
29
+ ```bash
30
+ mailos read -n 10
31
+ ```
32
+
33
+ ## Features
34
+
35
+ - šŸ“§ Multiple email provider support (Gmail, Fastmail, Zoho, Outlook, Yahoo)
36
+ - šŸ“ Markdown email composition (automatically converted to HTML)
37
+ - šŸ” Advanced email search and filtering
38
+ - šŸ“Ž Attachment support
39
+ - šŸ”— Unsubscribe link detection
40
+ - šŸ’¾ Export emails to markdown files
41
+ - šŸ”’ Secure credential storage
42
+
43
+ ## Commands
44
+
45
+ ### Setup
46
+ ```bash
47
+ mailos setup
48
+ ```
49
+ Interactive setup wizard to configure your email account.
50
+
51
+ ### Send
52
+ ```bash
53
+ mailos send -t to@email.com -s "Subject" -b "Body"
54
+
55
+ # With attachments
56
+ mailos send -t to@email.com -s "Files" -b "See attached" -a file1.pdf -a file2.docx
57
+
58
+ # With CC and BCC
59
+ mailos send -t to@email.com -c cc@email.com -B bcc@email.com -s "Subject" -b "Body"
60
+ ```
61
+
62
+ ### Read
63
+ ```bash
64
+ # Read last 10 emails
65
+ mailos read
66
+
67
+ # Read unread emails
68
+ mailos read --unread
69
+
70
+ # Search by sender
71
+ mailos read --from sender@example.com
72
+
73
+ # Save as markdown files
74
+ mailos read --save-markdown --output-dir emails/
75
+ ```
76
+
77
+ ### Mark as Read
78
+ ```bash
79
+ # Mark specific emails
80
+ mailos mark-read --ids 1,2,3
81
+
82
+ # Mark all from sender
83
+ mailos mark-read --from notifications@example.com
84
+ ```
85
+
86
+ ### Delete
87
+ ```bash
88
+ # Delete specific emails
89
+ mailos delete --ids 1,2,3 --confirm
90
+
91
+ # Delete all from sender
92
+ mailos delete --from spam@example.com --confirm
93
+ ```
94
+
95
+ ### Unsubscribe
96
+ ```bash
97
+ # Find unsubscribe links
98
+ mailos unsubscribe --from newsletter@example.com
99
+
100
+ # Open unsubscribe link in browser
101
+ mailos unsubscribe --from newsletter@example.com --open
102
+ ```
103
+
104
+ ## Configuration
105
+
106
+ Configuration is stored in `~/.email/config.json` or in a local `.email/config.json` file.
107
+
108
+ ## Building from Source
109
+
110
+ If you want to build from source instead of using pre-built binaries:
111
+
112
+ 1. Clone the repository
113
+ 2. Install Go 1.21+
114
+ 3. Run `npm install -g .` from the npm directory
115
+
116
+ ## License
117
+
118
+ MIT
119
+
120
+ ## Support
121
+
122
+ For issues and feature requests, visit: https://github.com/emailos/mailos/issues
package/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * mailos - EmailOS CLI
3
+ *
4
+ * This package provides a Node.js wrapper for the mailos Go binary.
5
+ * The actual functionality is implemented in Go and compiled to a native binary.
6
+ *
7
+ * @see https://github.com/emailos/mailos
8
+ */
9
+
10
+ module.exports = {
11
+ name: 'mailos',
12
+ version: require('./package.json').version,
13
+ description: 'EmailOS - A standardized email client CLI'
14
+ };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "mailos",
3
+ "version": "0.1.6",
4
+ "description": "Command-line email client with AI integration and support for multiple providers",
5
+ "keywords": [
6
+ "email",
7
+ "cli",
8
+ "gmail",
9
+ "fastmail",
10
+ "zoho",
11
+ "outlook",
12
+ "smtp",
13
+ "imap",
14
+ "markdown"
15
+ ],
16
+ "homepage": "https://email-os.com",
17
+ "bugs": {
18
+ "url": "https://github.com/emailos/mailos/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/emailos/mailos.git"
23
+ },
24
+ "license": "Proprietary",
25
+ "author": "EmailOS Team",
26
+ "main": "index.js",
27
+ "bin": {
28
+ "mailos": "./bin/mailos"
29
+ },
30
+ "scripts": {
31
+ "postinstall": "node scripts/install.js",
32
+ "preuninstall": "node scripts/uninstall.js",
33
+ "prepublishOnly": "rm -rf bin"
34
+ },
35
+ "engines": {
36
+ "node": ">=14.0.0"
37
+ },
38
+ "os": [
39
+ "darwin",
40
+ "linux",
41
+ "win32"
42
+ ],
43
+ "cpu": [
44
+ "x64",
45
+ "arm64"
46
+ ],
47
+ "dependencies": {
48
+ "node-fetch": "^2.6.7",
49
+ "tar": "^6.1.11",
50
+ "rimraf": "^3.0.2"
51
+ }
52
+ }
package/publish.sh ADDED
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+
3
+ echo "šŸ“¦ Preparing to publish mailos to NPM..."
4
+
5
+ # Clean up any existing binaries
6
+ rm -rf bin/
7
+
8
+ # Check if logged in to NPM
9
+ if ! npm whoami >/dev/null 2>&1; then
10
+ echo "āŒ Not logged in to NPM. Please run 'npm login' first."
11
+ exit 1
12
+ fi
13
+
14
+ # Dry run first
15
+ echo "Running dry-run..."
16
+ npm publish --dry-run
17
+
18
+ echo ""
19
+ echo "šŸ“‹ Review the above output. Continue with publish? (y/N)"
20
+ read -r response
21
+
22
+ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
23
+ echo "Publishing to NPM..."
24
+ npm publish
25
+ echo "āœ… Published successfully!"
26
+ else
27
+ echo "āŒ Publish cancelled."
28
+ fi
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
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
+
10
+ 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
+
15
+ // Platform mapping
16
+ const PLATFORM_MAPPING = {
17
+ 'darwin-x64': 'darwin-amd64',
18
+ 'darwin-arm64': 'darwin-arm64',
19
+ 'linux-x64': 'linux-amd64',
20
+ 'linux-arm64': 'linux-arm64',
21
+ 'win32-x64': 'windows-amd64',
22
+ 'win32-arm64': 'windows-arm64'
23
+ };
24
+
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
41
+ try {
42
+ const releaseUrl = `https://api.github.com/repos/${GITHUB_REPO}/releases/tags/v${VERSION}`;
43
+ const response = await fetch(releaseUrl);
44
+
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
+ }
57
+ }
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
+
136
+ const binDir = path.join(__dirname, '..', 'bin');
137
+ if (!fs.existsSync(binDir)) {
138
+ fs.mkdirSync(binDir, { recursive: true });
139
+ }
140
+
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
+ }
161
+ }
162
+
163
+ console.log('\nāœ“ mailos installed successfully!');
164
+ console.log('Run "mailos help" to get started.');
165
+
166
+ } catch (error) {
167
+ console.error('Installation failed:', error.message);
168
+ process.exit(1);
169
+ }
170
+ }
171
+
172
+ // Run installation
173
+ install();
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const rimraf = require('rimraf');
6
+
7
+ const binDir = path.join(__dirname, '..', 'bin');
8
+
9
+ console.log('Cleaning up mailos binary...');
10
+
11
+ try {
12
+ if (fs.existsSync(binDir)) {
13
+ rimraf.sync(binDir);
14
+ console.log('āœ“ Cleanup complete');
15
+ }
16
+ } catch (error) {
17
+ console.error('Cleanup failed:', error.message);
18
+ }