@taleshape/shaper 0.1.0
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 -0
- package/install.js +92 -0
- package/package.json +45 -0
- package/uninstall.js +17 -0
package/index.js
ADDED
package/install.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const axios = require('axios');
|
|
5
|
+
|
|
6
|
+
const BIN_DIR = path.join(__dirname, 'bin');
|
|
7
|
+
const VERSION = require('./package.json').version;
|
|
8
|
+
|
|
9
|
+
// Map of platform names to GitHub release asset names
|
|
10
|
+
const PLATFORM_MAP = {
|
|
11
|
+
'linux-x64': 'shaper-linux-amd64',
|
|
12
|
+
'linux-arm64': 'shaper-linux-arm64',
|
|
13
|
+
'darwin-x64': 'shaper-darwin-amd64',
|
|
14
|
+
'darwin-arm64': 'shaper-darwin-arm64',
|
|
15
|
+
// 'win32-x64': 'shaper_Windows_x86_64.zip',
|
|
16
|
+
// 'win32-arm64': 'shaper_Windows_arm64.zip'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
async function getRelease(version) {
|
|
20
|
+
try {
|
|
21
|
+
const response = await axios.get(
|
|
22
|
+
`https://api.github.com/repos/taleshape-com/shaper/releases/tags/v${version}`,
|
|
23
|
+
{
|
|
24
|
+
headers: {
|
|
25
|
+
'Accept': 'application/vnd.github.v3+json',
|
|
26
|
+
'User-Agent': 'shaper-installer'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
return response.data;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (error.response?.status === 404) {
|
|
33
|
+
console.error(`Version v${version} not found. Please check if this version exists in the releases.`);
|
|
34
|
+
} else {
|
|
35
|
+
console.error('Error fetching release:', error.message);
|
|
36
|
+
}
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function downloadFile(url, dest) {
|
|
42
|
+
const response = await axios({
|
|
43
|
+
method: 'GET',
|
|
44
|
+
url: url,
|
|
45
|
+
responseType: 'stream'
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const writer = fs.createWriteStream(dest);
|
|
49
|
+
response.data.pipe(writer);
|
|
50
|
+
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
writer.on('finish', resolve);
|
|
53
|
+
writer.on('error', reject);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function main() {
|
|
58
|
+
// Create bin directory if it doesn't exist
|
|
59
|
+
if (!fs.existsSync(BIN_DIR)) {
|
|
60
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
64
|
+
const assetName = PLATFORM_MAP[platform];
|
|
65
|
+
|
|
66
|
+
if (!assetName) {
|
|
67
|
+
console.error(`Unsupported platform: ${platform}`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const release = await getRelease(VERSION);
|
|
73
|
+
const asset = release.assets.find(a => a.name === assetName);
|
|
74
|
+
|
|
75
|
+
if (!asset) {
|
|
76
|
+
console.error(`Asset not found for platform ${platform} in version v${VERSION}`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
console.log(`Downloading shaper v${VERSION} for ${platform}...`);
|
|
81
|
+
const binaryPath = path.join(BIN_DIR, 'shaper');
|
|
82
|
+
await downloadFile(asset.browser_download_url, binaryPath);
|
|
83
|
+
fs.chmodSync(binaryPath, '755');
|
|
84
|
+
|
|
85
|
+
console.log('Installation complete!');
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error('Installation failed:', error);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taleshape/shaper",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Minimal Embedded Analytics and Data Platform",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"shaper": "./bin/shaper"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node install.js",
|
|
11
|
+
"preuninstall": "node uninstall.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin",
|
|
15
|
+
"index.js",
|
|
16
|
+
"install.js",
|
|
17
|
+
"uninstall.js"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"data",
|
|
21
|
+
"analytics",
|
|
22
|
+
"dashboards",
|
|
23
|
+
"duckdb"
|
|
24
|
+
],
|
|
25
|
+
"author": "Taleshape <hi@taleshape.com>",
|
|
26
|
+
"license": "UNLICENSED",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/taleshape-com/shaper.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/taleshape-com/shaper/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://taleshape.com/shaper",
|
|
35
|
+
"private": false,
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"axios": "^1.6.7"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/uninstall.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const BIN_DIR = path.join(__dirname, 'bin');
|
|
5
|
+
const BINARY_PATH = path.join(BIN_DIR, 'shaper');
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
if (fs.existsSync(BINARY_PATH)) {
|
|
9
|
+
fs.unlinkSync(BINARY_PATH);
|
|
10
|
+
}
|
|
11
|
+
if (fs.existsSync(BIN_DIR)) {
|
|
12
|
+
fs.rmdirSync(BIN_DIR);
|
|
13
|
+
}
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error('Error during uninstall:', error);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|