@taleshape/shaper 0.24.0 → 0.24.3

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