@taleshape/shaper 0.23.5 → 0.24.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 +5 -2
- package/package.json +8 -11
- package/bin/SHA256SUMS +0 -4
- package/bin/shaper +0 -10
- package/install.js +0 -149
- package/uninstall.js +0 -19
package/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MPL-2.0
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const { getBinaryPath } = require('./bin/get-binary');
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
|
-
|
|
6
|
+
get path() {
|
|
7
|
+
return getBinaryPath();
|
|
8
|
+
},
|
|
9
|
+
getBinaryPath,
|
|
7
10
|
};
|
package/package.json
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taleshape/shaper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "Minimal Embedded Analytics and Data Platform",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"shaper": "./bin/shaper"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"postinstall": "node install.js",
|
|
11
|
-
"preuninstall": "node uninstall.js"
|
|
7
|
+
"shaper": "./bin/shaper.js"
|
|
12
8
|
},
|
|
13
9
|
"files": [
|
|
14
10
|
"bin",
|
|
15
11
|
"README.md",
|
|
16
12
|
"LICENSE",
|
|
17
|
-
"index.js"
|
|
18
|
-
"install.js",
|
|
19
|
-
"uninstall.js"
|
|
13
|
+
"index.js"
|
|
20
14
|
],
|
|
21
15
|
"keywords": [
|
|
22
16
|
"data",
|
|
@@ -38,8 +32,11 @@
|
|
|
38
32
|
"publishConfig": {
|
|
39
33
|
"access": "public"
|
|
40
34
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
35
|
+
"optionalDependencies": {
|
|
36
|
+
"@taleshape/shaper-darwin-arm64": "0.24.1",
|
|
37
|
+
"@taleshape/shaper-darwin-x64": "0.24.1",
|
|
38
|
+
"@taleshape/shaper-linux-arm64": "0.24.1",
|
|
39
|
+
"@taleshape/shaper-linux-x64": "0.24.1"
|
|
43
40
|
},
|
|
44
41
|
"engines": {
|
|
45
42
|
"node": ">=18"
|
package/bin/SHA256SUMS
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
28e1a34007b674d28fd0d3e5f3591097f9d8352c8ebd4b26467db5b29a4eb736 shaper-darwin-arm64
|
|
2
|
-
a5f01595786e1ac287227cee0b48b762ba956aa13630fe8e8ba400b5491e393e shaper-linux-amd64
|
|
3
|
-
aad25d2d50a8c10f0d4cdf53a55dee73700a2c3f7118ac6c7142019977ad7b9b shaper-linux-arm64
|
|
4
|
-
dbf0aa88695e723534dfe172e94f3a3581af4303d67f05f60d9367321002e647 shaper-darwin-amd64
|
package/bin/shaper
DELETED
package/install.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const crypto = require('crypto');
|
|
7
|
-
const axios = require('axios');
|
|
8
|
-
|
|
9
|
-
const BIN_DIR = path.join(__dirname, 'bin');
|
|
10
|
-
const VERSION = require('./package.json').version;
|
|
11
|
-
|
|
12
|
-
// Map of platform names to GitHub release asset names
|
|
13
|
-
const PLATFORM_MAP = {
|
|
14
|
-
'linux-x64': 'shaper-linux-amd64',
|
|
15
|
-
'linux-arm64': 'shaper-linux-arm64',
|
|
16
|
-
'darwin-x64': 'shaper-darwin-amd64',
|
|
17
|
-
'darwin-arm64': 'shaper-darwin-arm64',
|
|
18
|
-
// 'win32-x64': 'shaper_Windows_x86_64.zip',
|
|
19
|
-
// 'win32-arm64': 'shaper_Windows_arm64.zip'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
async function getRelease(version) {
|
|
23
|
-
try {
|
|
24
|
-
const response = await axios.get(
|
|
25
|
-
`https://api.github.com/repos/taleshape-com/shaper/releases/tags/v${version}`,
|
|
26
|
-
{
|
|
27
|
-
headers: {
|
|
28
|
-
'Accept': 'application/vnd.github.v3+json',
|
|
29
|
-
'User-Agent': 'shaper-installer'
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
return response.data;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
if (error.response?.status === 404) {
|
|
36
|
-
throw new Error(`Version v${version} not found. Please check if this version exists in the releases.`);
|
|
37
|
-
}
|
|
38
|
-
throw new Error(`Error fetching release: ${error.message}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async function downloadFile(url, dest) {
|
|
43
|
-
const response = await axios({
|
|
44
|
-
method: 'GET',
|
|
45
|
-
url: url,
|
|
46
|
-
responseType: 'stream',
|
|
47
|
-
maxContentLength: 200 * 1024 * 1024, // 200MB max
|
|
48
|
-
validateStatus: status => status === 200
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const writer = fs.createWriteStream(dest);
|
|
52
|
-
response.data.pipe(writer);
|
|
53
|
-
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
55
|
-
writer.on('finish', resolve);
|
|
56
|
-
writer.on('error', reject);
|
|
57
|
-
response.data.on('error', reject);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function calculateSHA256(filePath) {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
const hash = crypto.createHash('sha256');
|
|
64
|
-
const stream = fs.createReadStream(filePath);
|
|
65
|
-
|
|
66
|
-
stream.on('error', err => reject(err));
|
|
67
|
-
stream.on('data', chunk => hash.update(chunk));
|
|
68
|
-
stream.on('end', () => resolve(hash.digest('hex')));
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function verifyChecksum(filePath, expectedChecksum) {
|
|
73
|
-
const actualChecksum = await calculateSHA256(filePath);
|
|
74
|
-
if (actualChecksum !== expectedChecksum) {
|
|
75
|
-
throw new Error(`Checksum verification failed for ${path.basename(filePath)}\nExpected: ${expectedChecksum}\nActual: ${actualChecksum}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function loadChecksums() {
|
|
80
|
-
const checksumsPath = path.join(__dirname, 'bin', 'SHA256SUMS');
|
|
81
|
-
if (!fs.existsSync(checksumsPath)) {
|
|
82
|
-
throw new Error('SHA256SUMS file not found in package');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const checksumsContent = fs.readFileSync(checksumsPath, 'utf8');
|
|
86
|
-
const checksums = {};
|
|
87
|
-
checksumsContent.split('\n').forEach(line => {
|
|
88
|
-
if (line.trim()) {
|
|
89
|
-
const [checksum, filename] = line.split(/\s+/);
|
|
90
|
-
checksums[filename] = checksum;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return checksums;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async function main() {
|
|
98
|
-
try {
|
|
99
|
-
// Create bin directory if it doesn't exist
|
|
100
|
-
if (!fs.existsSync(BIN_DIR)) {
|
|
101
|
-
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const platform = `${process.platform}-${process.arch}`;
|
|
105
|
-
const assetName = PLATFORM_MAP[platform];
|
|
106
|
-
|
|
107
|
-
if (!assetName) {
|
|
108
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Load checksums from the package
|
|
112
|
-
console.log('Loading checksums...');
|
|
113
|
-
const checksums = loadChecksums();
|
|
114
|
-
const expectedChecksum = checksums[assetName];
|
|
115
|
-
|
|
116
|
-
if (!expectedChecksum) {
|
|
117
|
-
throw new Error(`No checksum found for ${assetName} in SHA256SUMS`);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const release = await getRelease(VERSION);
|
|
121
|
-
const asset = release.assets.find(a => a.name === assetName);
|
|
122
|
-
|
|
123
|
-
if (!asset) {
|
|
124
|
-
throw new Error(`Asset not found for platform ${platform} in version v${VERSION}`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
console.log(`Downloading shaper v${VERSION} for ${platform}...`);
|
|
128
|
-
const binaryPath = path.join(BIN_DIR, 'shaper');
|
|
129
|
-
await downloadFile(asset.browser_download_url, binaryPath);
|
|
130
|
-
|
|
131
|
-
// Verify checksum
|
|
132
|
-
console.log('Verifying checksum...');
|
|
133
|
-
await verifyChecksum(binaryPath, expectedChecksum);
|
|
134
|
-
console.log('Checksum verified successfully');
|
|
135
|
-
|
|
136
|
-
// Set executable permissions
|
|
137
|
-
fs.chmodSync(binaryPath, '755');
|
|
138
|
-
|
|
139
|
-
console.log('Installation complete!');
|
|
140
|
-
} catch (error) {
|
|
141
|
-
console.error('Installation failed:', error.message);
|
|
142
|
-
// Clean up binary if verification failed
|
|
143
|
-
const binaryPath = path.join(BIN_DIR, 'shaper');
|
|
144
|
-
if (fs.existsSync(binaryPath)) fs.unlinkSync(binaryPath);
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
main();
|
package/uninstall.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
const BIN_DIR = path.join(__dirname, 'bin');
|
|
7
|
-
const BINARY_PATH = path.join(BIN_DIR, 'shaper');
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
if (fs.existsSync(BINARY_PATH)) {
|
|
11
|
-
fs.unlinkSync(BINARY_PATH);
|
|
12
|
-
}
|
|
13
|
-
if (fs.existsSync(BIN_DIR)) {
|
|
14
|
-
fs.rmdirSync(BIN_DIR);
|
|
15
|
-
}
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.error('Error during uninstall:', error);
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|