dataset-cli 1.0.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.
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ const path = require('path');
3
+ const os = require('os');
4
+
5
+ const platformMap = {
6
+ 'darwin-x64': 'darwin-amd64',
7
+ 'darwin-arm64': 'darwin-arm64',
8
+ 'linux-x64': 'linux-amd64',
9
+ 'linux-arm64': 'linux-arm64',
10
+ 'win32-x64': 'windows-amd64.exe'
11
+ };
12
+
13
+ const platform = `${os.platform()}-${os.arch()}`;
14
+ const binaryName = platformMap[platform] || platform;
15
+
16
+ const binaryPath = path.join(__dirname, 'bin', binaryName);
17
+
18
+ const { spawn } = require('child_process');
19
+ const child = spawn(binaryPath, process.argv.slice(2), {
20
+ stdio: 'inherit',
21
+ cwd: process.cwd()
22
+ });
23
+
24
+ child.on('exit', (code) => {
25
+ process.exit(code);
26
+ });
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "dataset-cli",
3
+ "version": "1.0.0",
4
+ "description": "Dataset processing CLI tool",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/darshan192004/cli-project.git"
8
+ },
9
+ "bin": {
10
+ "dataset-cli": "bin/launcher.js"
11
+ },
12
+ "scripts": {
13
+ "postinstall": "node scripts/install.js"
14
+ }
15
+ }
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const os = require('os');
5
+ const https = require('https');
6
+ const { execSync } = require('child_process');
7
+
8
+ const platformMap = {
9
+ 'darwin-x64': 'darwin-amd64',
10
+ 'darwin-arm64': 'darwin-arm64',
11
+ 'linux-x64': 'linux-amd64',
12
+ 'linux-arm64': 'linux-arm64',
13
+ 'win32-x64': 'windows-amd64.exe'
14
+ };
15
+
16
+ const platform = `${os.platform()}-${os.arch()}`;
17
+ const binaryName = platformMap[platform];
18
+
19
+ if (!binaryName) {
20
+ console.error(`Unsupported platform: ${platform}`);
21
+ process.exit(1);
22
+ }
23
+
24
+ const installDir = path.join(__dirname, 'bin');
25
+ const binaryPath = path.join(installDir, binaryName);
26
+
27
+ if (fs.existsSync(binaryPath)) {
28
+ return;
29
+ }
30
+
31
+ const version = require(path.join(__dirname, '..', 'package.json')).version;
32
+ const repo = 'darshan192004/cli-project';
33
+ const downloadUrl = `https://github.com/${repo}/releases/download/v${version}/dataset-cli-${binaryName}`;
34
+
35
+ console.log(`Downloading dataset-cli v${version} for ${platform}...`);
36
+
37
+ const file = fs.createWriteStream(binaryPath);
38
+
39
+ https.get(downloadUrl, (response) => {
40
+ if (response.statusCode === 302 || response.statusCode === 301) {
41
+ https.get(response.headers.location, (redirectResponse) => {
42
+ redirectResponse.pipe(file);
43
+ file.on('finish', () => {
44
+ file.close();
45
+ fs.chmodSync(binaryPath, 0o755);
46
+ console.log(`Installed dataset-cli v${version}`);
47
+ });
48
+ });
49
+ } else {
50
+ response.pipe(file);
51
+ file.on('finish', () => {
52
+ file.close();
53
+ fs.chmodSync(binaryPath, 0o755);
54
+ console.log(`Installed dataset-cli v${version}`);
55
+ });
56
+ }
57
+ }).on('error', (err) => {
58
+ fs.unlink(binaryPath, () => {});
59
+ console.error(`Failed to download: ${err.message}`);
60
+ process.exit(1);
61
+ });