moledb 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.
Files changed (3) hide show
  1. package/bin/mole +12 -0
  2. package/install.js +73 -0
  3. package/package.json +21 -0
package/bin/mole ADDED
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -x "$basedir/node" ]; then
9
+ exec "$basedir/node" "$basedir/../mole-cli/bin/mole-cli" "$@"
10
+ else
11
+ exec node "$basedir/../mole-cli/bin/mole-cli" "$@"
12
+ fi
package/install.js ADDED
@@ -0,0 +1,73 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const https = require('https');
4
+ const { execSync } = require('child_process');
5
+
6
+ // Configuration
7
+ const VERSION = 'v0.0.1'; // Update this to match the tag you want to download
8
+ const REPO = 'shivang-16/mole_db';
9
+ const BIN_NAME = 'mole-cli';
10
+
11
+ // Detect OS and Arch
12
+ const osMap = {
13
+ 'darwin': 'darwin',
14
+ 'linux': 'linux',
15
+ 'win32': 'windows'
16
+ };
17
+ const archMap = {
18
+ 'x64': 'amd64',
19
+ 'arm64': 'arm64'
20
+ };
21
+
22
+ const platform = osMap[process.platform];
23
+ const arch = archMap[process.arch];
24
+
25
+ if (!platform || !arch) {
26
+ console.error(`Unsupported platform: ${process.platform} ${process.arch}`);
27
+ process.exit(1);
28
+ }
29
+
30
+ const binaryName = `${BIN_NAME}-${platform}-${arch}${platform === 'windows' ? '.exe' : ''}`;
31
+ const downloadUrl = `https://github.com/${REPO}/releases/download/${VERSION}/${binaryName}`;
32
+ const dest = path.join(__dirname, 'bin', platform === 'windows' ? 'mole.exe' : 'mole');
33
+
34
+ console.log(`Downloading mole-cli ${VERSION} for ${platform}/${arch}...`);
35
+
36
+ if (!fs.existsSync(path.join(__dirname, 'bin'))) {
37
+ fs.mkdirSync(path.join(__dirname, 'bin'));
38
+ }
39
+
40
+ const file = fs.createWriteStream(dest);
41
+
42
+ https.get(downloadUrl, (response) => {
43
+ if (response.statusCode === 302) {
44
+ // Handle redirect
45
+ https.get(response.headers.location, (response) => {
46
+ response.pipe(file);
47
+ file.on('finish', () => {
48
+ file.close();
49
+ if (platform !== 'windows') {
50
+ fs.chmodSync(dest, 0o755); // Make executable
51
+ }
52
+ console.log('Download complete!');
53
+ });
54
+ });
55
+ } else if (response.statusCode !== 200) {
56
+ console.error(`Failed to download binary: HTTP ${response.statusCode}`);
57
+ console.error(downloadUrl);
58
+ process.exit(1);
59
+ } else {
60
+ response.pipe(file);
61
+ file.on('finish', () => {
62
+ file.close();
63
+ if (platform !== 'windows') {
64
+ fs.chmodSync(dest, 0o755);
65
+ }
66
+ console.log('Download complete!');
67
+ });
68
+ }
69
+ }).on('error', (err) => {
70
+ fs.unlink(dest, () => {});
71
+ console.error(`Error downloading file: ${err.message}`);
72
+ process.exit(1);
73
+ });
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "moledb",
3
+ "version": "0.0.1",
4
+ "description": "The official CLI for Mole DB",
5
+ "bin": {
6
+ "mole": "./bin/mole"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/shivang-16/mole_db.git"
14
+ },
15
+ "author": "Shivang",
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "axios": "^1.6.0",
19
+ "tar": "^6.2.0"
20
+ }
21
+ }