@alius-tech/alius-darwin-x64 0.0.1
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/index.js +34 -0
- package/package.json +44 -0
- package/scripts/download.js +157 -0
package/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @alius-tech/alius-darwin-x64
|
|
3
|
+
* Platform-specific binary package for Alius CLI
|
|
4
|
+
*
|
|
5
|
+
* @author Alius Tech
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
|
|
11
|
+
const binaryName = 'alius';
|
|
12
|
+
const binaryPath = path.join(__dirname, 'bin', binaryName);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get the path to the native binary
|
|
16
|
+
* @returns {string} Absolute path to the binary
|
|
17
|
+
*/
|
|
18
|
+
function getBinaryPath() {
|
|
19
|
+
if (!fs.existsSync(binaryPath)) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Binary not found at ${binaryPath}. \n` +
|
|
22
|
+
`Run 'npm install' to download the binary, or download manually from:\n` +
|
|
23
|
+
`https://github.com/AliusTech/alius/releases`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return binaryPath;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
binaryPath: binaryPath,
|
|
31
|
+
getBinaryPath: getBinaryPath,
|
|
32
|
+
binaryName: binaryName,
|
|
33
|
+
platform: 'darwin-x64',
|
|
34
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alius-tech/alius-darwin-x64",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Alius CLI binary for macOS Intel (x86_64)",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Alius Tech",
|
|
7
|
+
"email": "alius@aliustech.com",
|
|
8
|
+
"url": "https://aliustech.com"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/AliusTech/alius.git",
|
|
14
|
+
"directory": "npm-packages/alius-darwin-x64"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/AliusTech/alius#readme",
|
|
17
|
+
"main": "index.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./index.js",
|
|
20
|
+
"./binary": "./index.js"
|
|
21
|
+
},
|
|
22
|
+
"binary": {
|
|
23
|
+
"artifact": "alius-macos-x64.tar.gz",
|
|
24
|
+
"downloadUrl": "https://github.com/AliusTech/alius/releases/download/v0.0.1/alius-macos-x64.tar.gz"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"bin",
|
|
28
|
+
"scripts",
|
|
29
|
+
"index.js",
|
|
30
|
+
"package.json"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"postinstall": "node scripts/download.js"
|
|
34
|
+
},
|
|
35
|
+
"os": [
|
|
36
|
+
"darwin"
|
|
37
|
+
],
|
|
38
|
+
"cpu": [
|
|
39
|
+
"x64"
|
|
40
|
+
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=16"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Download script for @alius-tech/alius-darwin-x64
|
|
4
|
+
* Downloads the native binary from GitHub Releases
|
|
5
|
+
*
|
|
6
|
+
* @author Alius Tech
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const https = require('https');
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { execSync } = require('child_process');
|
|
13
|
+
|
|
14
|
+
// Package configuration
|
|
15
|
+
const pkg = require('../package.json');
|
|
16
|
+
const VERSION = pkg.version;
|
|
17
|
+
const ARTIFACT = pkg.binary.artifact || 'alius-macos-x64.tar.gz';
|
|
18
|
+
const BINARY_NAME = 'alius';
|
|
19
|
+
const GITHUB_REPO = 'AliusTech/alius';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Download file from URL with redirect support
|
|
23
|
+
*/
|
|
24
|
+
async function downloadFile(url, destPath) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const file = fs.createWriteStream(destPath);
|
|
27
|
+
|
|
28
|
+
const request = (url) => {
|
|
29
|
+
https.get(url, (response) => {
|
|
30
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
31
|
+
request(response.headers.location);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (response.statusCode !== 200) {
|
|
36
|
+
reject(new Error(`Download failed: HTTP ${response.statusCode}`));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const totalSize = parseInt(response.headers['content-length'], 10);
|
|
41
|
+
let downloadedSize = 0;
|
|
42
|
+
|
|
43
|
+
response.on('data', (chunk) => {
|
|
44
|
+
downloadedSize += chunk.length;
|
|
45
|
+
if (totalSize) {
|
|
46
|
+
const percent = Math.round((downloadedSize / totalSize) * 100);
|
|
47
|
+
if (percent % 10 === 0) {
|
|
48
|
+
console.log(`Downloading... ${percent}%`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
response.pipe(file);
|
|
54
|
+
|
|
55
|
+
file.on('finish', () => {
|
|
56
|
+
file.close();
|
|
57
|
+
resolve();
|
|
58
|
+
});
|
|
59
|
+
}).on('error', (err) => {
|
|
60
|
+
fs.unlink(destPath, () => {});
|
|
61
|
+
reject(err);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
request(url);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Extract archive to destination directory
|
|
71
|
+
*/
|
|
72
|
+
function extractArchive(archivePath, destDir) {
|
|
73
|
+
console.log('Extracting binary...');
|
|
74
|
+
|
|
75
|
+
if (archivePath.endsWith('.tar.gz')) {
|
|
76
|
+
execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { stdio: 'inherit' });
|
|
77
|
+
} else if (archivePath.endsWith('.zip')) {
|
|
78
|
+
if (process.platform === 'win32') {
|
|
79
|
+
execSync(`powershell -command "Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force"`, { stdio: 'inherit' });
|
|
80
|
+
} else {
|
|
81
|
+
execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { stdio: 'inherit' });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Main installation process
|
|
88
|
+
*/
|
|
89
|
+
async function install() {
|
|
90
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
91
|
+
const binaryPath = path.join(binDir, BINARY_NAME);
|
|
92
|
+
const downloadUrl = pkg.binary.downloadUrl || `https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/${ARTIFACT}`;
|
|
93
|
+
const archivePath = path.join(binDir, ARTIFACT);
|
|
94
|
+
|
|
95
|
+
// Check if binary already exists
|
|
96
|
+
if (fs.existsSync(binaryPath)) {
|
|
97
|
+
console.log(`✓ Binary already installed at ${binaryPath}`);
|
|
98
|
+
console.log(` To reinstall, remove the file and run npm install again.`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Create bin directory
|
|
103
|
+
if (!fs.existsSync(binDir)) {
|
|
104
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.log(`\nInstalling Alius CLI binary...`);
|
|
108
|
+
console.log(`Platform: macOS Intel (x86_64)`);
|
|
109
|
+
console.log(`Version: ${VERSION}`);
|
|
110
|
+
console.log(`Artifact: ${ARTIFACT}\n`);
|
|
111
|
+
|
|
112
|
+
// Download the archive
|
|
113
|
+
try {
|
|
114
|
+
await downloadFile(downloadUrl, archivePath);
|
|
115
|
+
console.log('✓ Download complete');
|
|
116
|
+
} catch (err) {
|
|
117
|
+
console.error(`✗ Download failed: ${err.message}`);
|
|
118
|
+
console.error(`\nManual download:`);
|
|
119
|
+
console.error(` URL: ${downloadUrl}`);
|
|
120
|
+
console.error(` Extract to: ${binDir}`);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Extract the binary
|
|
125
|
+
try {
|
|
126
|
+
extractArchive(archivePath, binDir);
|
|
127
|
+
console.log('✓ Extraction complete');
|
|
128
|
+
} catch (err) {
|
|
129
|
+
console.error(`✗ Extraction failed: ${err.message}`);
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Clean up archive
|
|
134
|
+
fs.unlinkSync(archivePath);
|
|
135
|
+
|
|
136
|
+
// Make binary executable (Unix)
|
|
137
|
+
if (process.platform !== 'win32' && fs.existsSync(binaryPath)) {
|
|
138
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Verify installation
|
|
142
|
+
if (!fs.existsSync(binaryPath)) {
|
|
143
|
+
console.error(`✗ Binary not found at ${binaryPath}`);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
console.log(`\n✓ Successfully installed Alius CLI!`);
|
|
148
|
+
console.log(` Binary: ${binaryPath}\n`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Run installation
|
|
152
|
+
install().catch((err) => {
|
|
153
|
+
console.error(`\n✗ Installation failed: ${err.message}`);
|
|
154
|
+
console.error(`\nFor manual installation, download from:`);
|
|
155
|
+
console.error(` https://github.com/${GITHUB_REPO}/releases/tag/v${VERSION}`);
|
|
156
|
+
process.exit(1);
|
|
157
|
+
});
|