@heetmehta18/autodev 0.1.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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -0
  3. package/bin/index.js +129 -0
  4. package/package.json +34 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AutoDev Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # AutoDev NPM CLI Wrapper
2
+
3
+ This package provides a lightweight Node.js wrapper around the native Go compiled binaries for AutoDev. It allows developers to run AutoDev seamlessly using standard Node package execution engines like `npx` or `pnpm dlx`, or by installing it globally via npm.
4
+
5
+ ## Usage
6
+
7
+ ### Run via npx (No Installation Needed)
8
+ ```bash
9
+ npx @heetmehta18/autodev --help
10
+ ```
11
+
12
+ ### Install Globally
13
+ ```bash
14
+ npm install -g @heetmehta18/autodev
15
+ autodev --help
16
+ ```
17
+
18
+ ## How It Works
19
+ 1. **Platform Detection:** The JavaScript wrapper reads `process.platform` and `process.arch` to map the user's platform to the target release asset names (e.g. `linux/amd64`, `windows/arm64`, `darwin/arm64`).
20
+ 2. **Dynamic Download:** If the native binary is not yet cached locally in this package's `bin/` directory, the wrapper automatically downloads the correct compressed release (`.tar.gz` or `.zip`) directly from the corresponding GitHub Release tag (matching the `package.json` version).
21
+ 3. **Execution Delegation:** The wrapper spawns the native binary as a subprocess, forwarding all arguments, stdio streams, and exit codes. Future runs bypass the download step entirely for instant execution.
22
+ 4. **Development DX Mode:** During local development, if a compiled binary is found under `packages/cli/bin/autodev`, the wrapper forwards execution directly to the local dev build, bypassing remote GitHub requests.
23
+
24
+ ## Publishing
25
+ To publish updates to the npm registry:
26
+ 1. Ensure the package version matches the GitHub release tag:
27
+ ```bash
28
+ pnpm --filter=@heetmehta18/autodev version <new-version>
29
+ ```
30
+ 2. Publish to npm:
31
+ ```bash
32
+ pnpm --filter=@heetmehta18/autodev publish
33
+ ```
package/bin/index.js ADDED
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+ const { execSync } = require('child_process');
8
+
9
+ // Determine OS & Arch mapping
10
+ const platformMap = {
11
+ darwin: 'darwin',
12
+ linux: 'linux',
13
+ win32: 'windows',
14
+ };
15
+
16
+ const archMap = {
17
+ x64: 'amd64',
18
+ arm64: 'arm64',
19
+ };
20
+
21
+ const platform = platformMap[process.platform];
22
+ const arch = archMap[process.arch];
23
+
24
+ if (!platform || !arch) {
25
+ console.error(`[autodev] Unsupported platform/architecture: ${process.platform}/${process.arch}`);
26
+ process.exit(1);
27
+ }
28
+
29
+ const ext = platform === 'windows' ? 'zip' : 'tar.gz';
30
+ const binaryName = platform === 'windows' ? 'autodev.exe' : 'autodev';
31
+
32
+ // Version mapped to package.json
33
+ const pkgJson = require('../package.json');
34
+ const version = `v${pkgJson.version}`; // E.g., v0.1.0
35
+
36
+ // Resolve target paths
37
+ const binDir = path.join(__dirname, '..', 'bin');
38
+ const binaryPath = path.join(binDir, binaryName);
39
+
40
+ // Development fallback paths
41
+ const devPaths = [
42
+ path.join(__dirname, '..', '..', 'cli', 'bin', binaryName),
43
+ path.join(__dirname, '..', '..', '..', 'bin', binaryName),
44
+ path.join(__dirname, '..', '..', '..', 'packages', 'cli', 'bin', binaryName),
45
+ ];
46
+
47
+ let activeBinaryPath = binaryPath;
48
+
49
+ // Check if we are running in local dev mode and have a compiled binary
50
+ for (const devPath of devPaths) {
51
+ if (fs.existsSync(devPath)) {
52
+ activeBinaryPath = devPath;
53
+ break;
54
+ }
55
+ }
56
+
57
+ function downloadBinary() {
58
+ console.log(`\n[autodev] Native binary not found. Downloading AutoDev ${version} for ${platform}/${arch}...`);
59
+
60
+ if (!fs.existsSync(binDir)) {
61
+ fs.mkdirSync(binDir, { recursive: true });
62
+ }
63
+
64
+ // Construct download URL
65
+ const archiveName = `autodev_${platform}_${arch}`;
66
+ const archiveFile = `${archiveName}.${ext}`;
67
+ // Using the user's repository URL
68
+ const url = `https://github.com/HEETMEHTA18/autodev/releases/download/${version}/${archiveFile}`;
69
+
70
+ const tempFile = path.join(os.tmpdir(), archiveFile);
71
+
72
+ // Download using curl / wget / powershell
73
+ try {
74
+ if (process.platform === 'win32') {
75
+ execSync(`powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '${url}' -OutFile '${tempFile}'"`, { stdio: 'inherit' });
76
+ } else {
77
+ if (spawnSync('command', ['-v', 'curl'], { shell: true }).status === 0) {
78
+ execSync(`curl -fsSL "${url}" -o "${tempFile}"`, { stdio: 'inherit' });
79
+ } else if (spawnSync('command', ['-v', 'wget'], { shell: true }).status === 0) {
80
+ execSync(`wget -q "${url}" -O "${tempFile}"`, { stdio: 'inherit' });
81
+ } else {
82
+ throw new Error('Neither curl nor wget was found on the system path.');
83
+ }
84
+ }
85
+ } catch (err) {
86
+ console.error(`\n[autodev] Error downloading release asset: ${err.message}`);
87
+ console.error(`Please verify that the release version ${version} exists and has compiled assets.`);
88
+ process.exit(1);
89
+ }
90
+
91
+ // Extract
92
+ console.log(`[autodev] Extracting binary...`);
93
+ try {
94
+ if (ext === 'zip') {
95
+ if (process.platform === 'win32') {
96
+ execSync(`powershell -Command "Expand-Archive -Path '${tempFile}' -DestinationPath '${binDir}' -Force"`, { stdio: 'inherit' });
97
+ } else {
98
+ execSync(`unzip -o "${tempFile}" -d "${binDir}"`, { stdio: 'inherit' });
99
+ }
100
+ } else {
101
+ execSync(`tar -xzf "${tempFile}" -C "${binDir}"`, { stdio: 'inherit' });
102
+ }
103
+
104
+ // Clean up temp archive
105
+ if (fs.existsSync(tempFile)) {
106
+ fs.unlinkSync(tempFile);
107
+ }
108
+
109
+ // Set execution permissions on Linux/macOS
110
+ if (process.platform !== 'win32') {
111
+ fs.chmodSync(binaryPath, 0o755);
112
+ }
113
+ console.log(`[autodev] Installation successful.\n`);
114
+ } catch (err) {
115
+ console.error(`\n[autodev] Error extracting archive: ${err.message}`);
116
+ process.exit(1);
117
+ }
118
+ }
119
+
120
+ // If no local dev binary is found and the packaged binary is missing, download it
121
+ if (activeBinaryPath === binaryPath && !fs.existsSync(binaryPath)) {
122
+ downloadBinary();
123
+ }
124
+
125
+ // Forward execution
126
+ const args = process.argv.slice(2);
127
+ const result = spawnSync(activeBinaryPath, args, { stdio: 'inherit' });
128
+
129
+ process.exit(result.status ?? 0);
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@heetmehta18/autodev",
3
+ "version": "0.1.1",
4
+ "description": "The App Store for Developers. Install languages, frameworks, and databases with a single command.",
5
+ "main": "bin/index.js",
6
+ "bin": {
7
+ "autodev": "bin/index.js"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/HEETMEHTA18/autodev.git"
15
+ },
16
+ "keywords": [
17
+ "autodev",
18
+ "developer",
19
+ "environment",
20
+ "installer",
21
+ "bootstrap",
22
+ "setup",
23
+ "cli"
24
+ ],
25
+ "author": "Heet Mehta",
26
+ "license": "MIT",
27
+ "bugs": {
28
+ "url": "https://github.com/HEETMEHTA18/autodev/issues"
29
+ },
30
+ "homepage": "https://github.com/HEETMEHTA18/autodev#readme",
31
+ "scripts": {
32
+ "test": "node bin/index.js --help"
33
+ }
34
+ }