@mandors/cli 0.0.20 → 0.0.22

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
package/npm/bin/mandor CHANGED
File without changes
@@ -25,9 +25,7 @@ function getPlatform() {
25
25
  }
26
26
 
27
27
  async function getLatestVersion(prerelease = false) {
28
- const url = prerelease
29
- ? `https://api.github.com/repos/${REPO}/releases`
30
- : `https://api.github.com/repos/${REPO}/releases/latest`;
28
+ const url = `https://api.github.com/repos/${REPO}/releases`;
31
29
 
32
30
  return new Promise((resolve, reject) => {
33
31
  https.get(url, { headers: { 'User-Agent': 'Mandor-CLI' } }, (res) => {
@@ -36,14 +34,9 @@ async function getLatestVersion(prerelease = false) {
36
34
  res.on('end', () => {
37
35
  try {
38
36
  const parsed = JSON.parse(data);
39
- let tagName = null;
40
- if (parsed && parsed.tag_name) {
41
- tagName = parsed.tag_name;
42
- } else if (Array.isArray(parsed) && parsed.length > 0 && parsed[0].tag_name) {
43
- tagName = parsed[0].tag_name;
44
- }
45
- if (tagName) {
46
- resolve(tagName.replace(/^v/, ''));
37
+ if (Array.isArray(parsed) && parsed.length > 0) {
38
+ const release = parsed[0];
39
+ resolve(release.tag_name.replace(/^v/, ''));
47
40
  } else {
48
41
  reject(new Error('No release found'));
49
42
  }
@@ -73,10 +66,8 @@ function downloadFile(url, dest) {
73
66
  });
74
67
  }
75
68
 
76
- async function install(options = {}) {
69
+ async function install() {
77
70
  const { platform, arch } = getPlatform();
78
- const version = options.version || 'latest';
79
- const prerelease = options.prerelease || false;
80
71
  const osArch = `${platform}-${arch}`;
81
72
  const binaryName = platform === 'win32' ? 'mandor.exe' : 'mandor';
82
73
 
@@ -84,13 +75,9 @@ async function install(options = {}) {
84
75
  console.log('================');
85
76
  console.log(`OS: ${osArch}`);
86
77
 
87
- let installVersion = version;
88
- if (version === 'latest') {
89
- console.log(`Fetching latest ${prerelease ? 'prerelease' : 'release'}...`);
90
- installVersion = await getLatestVersion(prerelease);
91
- }
92
-
93
- console.log(`Version: ${installVersion}`);
78
+ console.log('Fetching latest release...');
79
+ const version = await getLatestVersion();
80
+ console.log(`Version: ${version}`);
94
81
  console.log('');
95
82
 
96
83
  const binaryPath = path.join(INSTALL_DIR, binaryName);
@@ -101,7 +88,7 @@ async function install(options = {}) {
101
88
  }
102
89
 
103
90
  console.log('Downloading from GitHub releases...');
104
- const downloadUrl = `https://github.com/${REPO}/releases/download/v${installVersion}/${osArch}.tar.gz`;
91
+ const downloadUrl = `https://github.com/${REPO}/releases/download/v${version}/${osArch}.tar.gz`;
105
92
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mandor-'));
106
93
  const tarball = path.join(tempDir, `${osArch}.tar.gz`);
107
94
 
@@ -11,8 +11,6 @@ const os = require('os');
11
11
 
12
12
  const ROOT_DIR = path.join(__dirname, '..', '..');
13
13
  const BINARIES_DIR = path.join(ROOT_DIR, 'binaries');
14
- const NPM_DIR = path.join(ROOT_DIR, 'npm');
15
- const NPM_BINARIES_DIR = path.join(NPM_DIR, 'binaries');
16
14
 
17
15
  const PLATFORMS = [
18
16
  { os: 'darwin', arch: 'x64' },
@@ -73,17 +71,37 @@ function createArchive(platform) {
73
71
  }
74
72
  }
75
73
 
76
- function copyToNpm() {
77
- fs.mkdirSync(NPM_BINARIES_DIR, { recursive: true });
74
+ function uploadToGithubReleases(results) {
75
+ let version;
76
+ try {
77
+ version = execSync('git describe --tags --abbrev=0', { encoding: 'utf8' }).trim();
78
+ } catch {
79
+ const pkg = require(path.join(ROOT_DIR, 'package.json'));
80
+ version = pkg.version;
81
+ }
78
82
 
79
- for (const platform of PLATFORMS) {
80
- const { os, arch } = platform;
81
- const archivePath = path.join(BINARIES_DIR, `${os}-${arch}.tar.gz`);
82
- const destPath = path.join(NPM_BINARIES_DIR, `${os}-${arch}.tar.gz`);
83
+ const archives = results.filter(r => r.archivePath && fs.existsSync(r.archivePath));
83
84
 
84
- if (fs.existsSync(archivePath)) {
85
- fs.cpSync(archivePath, destPath);
86
- console.log(`Copied ${os}-${arch}.tar.gz to npm/`);
85
+ if (archives.length === 0) {
86
+ console.log('No archives to upload');
87
+ return;
88
+ }
89
+
90
+ console.log(`\nUploading ${archives.length} binaries to GitHub release ${version}...`);
91
+
92
+ for (const archive of archives) {
93
+ const assetPath = archive.archivePath;
94
+ const assetName = `${path.basename(path.dirname(assetPath))}.tar.gz`;
95
+
96
+ try {
97
+ console.log(` Uploading ${assetName}...`);
98
+ execSync(`gh release upload "${version}" "${assetPath}" --repo "${process.env.GITHUB_REPOSITORY || 'sanxzy/mandor'}"`, {
99
+ stdio: 'pipe',
100
+ shell: true
101
+ });
102
+ console.log(` Uploaded ${assetName}`);
103
+ } catch (error) {
104
+ console.error(` Failed to upload ${assetName}:`, error.message);
87
105
  }
88
106
  }
89
107
  }
@@ -103,7 +121,6 @@ function mainBuild() {
103
121
  console.log('Building cross-platform binaries...\n');
104
122
 
105
123
  cleanBuildDirs();
106
- fs.mkdirSync(NPM_BINARIES_DIR, { recursive: true });
107
124
 
108
125
  const results = [];
109
126
  const unsupported = [];
@@ -130,9 +147,6 @@ function mainBuild() {
130
147
  }
131
148
  }
132
149
 
133
- console.log('Copying archives to npm/binaries/ for npm package...');
134
- copyToNpm();
135
-
136
150
  console.log('─'.repeat(50));
137
151
  console.log(`Build complete!`);
138
152
  console.log(` Built: ${results.length} platforms`);
@@ -146,7 +160,8 @@ function mainBuild() {
146
160
  }
147
161
 
148
162
  console.log(`\nArchives location: ${BINARIES_DIR}/`);
149
- console.log(`NPM package binaries: ${NPM_BINARIES_DIR}/`);
163
+
164
+ uploadToGithubReleases(results);
150
165
 
151
166
  return results;
152
167
  }
@@ -162,4 +177,4 @@ if (require.main === module) {
162
177
  }
163
178
  }
164
179
 
165
- module.exports = { PLATFORMS, buildForPlatform, createArchive, mainBuild, copyToNpm };
180
+ module.exports = { PLATFORMS, buildForPlatform, createArchive, mainBuild };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@mandors/cli",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "Event-based task manager CLI for AI agent workflows",
5
- "main": "npm/lib/index.js",
5
+ "main": "lib/index.js",
6
6
  "bin": {
7
- "mandor": "./npm/bin/mandor"
7
+ "mandor": "./bin/mandor"
8
8
  },
9
9
  "os": [
10
10
  "darwin",