@mandors/cli 0.0.21 → 0.0.24
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/scripts/build.js
CHANGED
|
@@ -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
|
|
77
|
-
|
|
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
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
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
|
|
180
|
+
module.exports = { PLATFORMS, buildForPlatform, createArchive, mainBuild };
|