snpm 0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 snpm 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
13
+ all 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
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # snpm
2
+
3
+ **Speedy Node Package Manager** - A fast, Rust-based package manager that's a drop-in replacement for npm, yarn, and pnpm.
4
+
5
+ ## Installation
6
+
7
+ ### Via npm
8
+
9
+ ```bash
10
+ npm install -g snpm
11
+ ```
12
+
13
+ ### Via direct download
14
+
15
+ Download the latest release for your platform from [GitHub Releases](https://github.com/binbandit/snpm/releases).
16
+
17
+ ## Usage
18
+
19
+ Use `snpm` just like you would use `npm`:
20
+
21
+ ```bash
22
+ # Install dependencies
23
+ snpm install
24
+
25
+ # Add a package
26
+ snpm add react
27
+
28
+ # Remove a package
29
+ snpm remove lodash
30
+
31
+ # Run a script
32
+ snpm run build
33
+ ```
34
+
35
+ ## Features
36
+
37
+ - **Fast by Default**: Global caching, parallel downloads, and smart reuse
38
+ - **Deterministic**: Simple, readable lockfile (`snpm-lock.yaml`)
39
+ - **Workspace Support**: First-class monorepo support
40
+ - **Catalog Protocol**: Define versions in one place across your workspace
41
+ - **Minimum Version Age**: Protect against zero-day malicious packages
42
+
43
+ ## Documentation
44
+
45
+ For more information, visit the [snpm repository](https://github.com/binbandit/snpm).
46
+
47
+ ## License
48
+
49
+ MIT
package/bin/snpm.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require('child_process');
4
+ const { join } = require('path');
5
+ const { existsSync } = require('fs');
6
+
7
+ const binName = process.platform === 'win32' ? 'snpm.exe' : 'snpm';
8
+ const binPath = join(__dirname, binName);
9
+
10
+ if (!existsSync(binPath)) {
11
+ console.error('snpm binary not found. Please run: npm install');
12
+ console.error('If the problem persists, try reinstalling: npm install -g snpm --force');
13
+ process.exit(1);
14
+ }
15
+
16
+ const result = spawnSync(binPath, process.argv.slice(2), {
17
+ stdio: 'inherit',
18
+ windowsHide: false,
19
+ });
20
+
21
+ process.exit(result.status);
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "snpm",
3
+ "version": "0.0.0",
4
+ "description": "Speedy Node Package Manager - A fast, Rust-based package manager",
5
+ "bin": {
6
+ "snpm": "bin/snpm.js"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/binbandit/snpm.git"
11
+ },
12
+ "keywords": [
13
+ "package-manager",
14
+ "npm",
15
+ "pnpm",
16
+ "yarn",
17
+ "fast",
18
+ "rust"
19
+ ],
20
+ "author": "snpm contributors",
21
+ "license": "(MIT OR Apache-2.0)",
22
+ "engines": {
23
+ "node": ">=18.0.0"
24
+ },
25
+ "os": [
26
+ "darwin",
27
+ "linux",
28
+ "win32"
29
+ ],
30
+ "cpu": [
31
+ "x64",
32
+ "arm64"
33
+ ],
34
+ "files": [
35
+ "bin",
36
+ "scripts",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "dependencies": {
41
+ "tar": "^7.4.3",
42
+ "adm-zip": "^0.5.16"
43
+ },
44
+ "scripts": {
45
+ "postinstall": "node scripts/install.js",
46
+ "test": "node scripts/test.js"
47
+ }
48
+ }
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { existsSync, mkdirSync, chmodSync } = require('fs');
4
+ const { join } = require('path');
5
+ const { get } = require('https');
6
+ const { createWriteStream } = require('fs');
7
+ const { pipeline } = require('stream');
8
+ const { promisify } = require('util');
9
+ const { createGunzip } = require('zlib');
10
+ const tar = require('tar');
11
+
12
+ const streamPipeline = promisify(pipeline);
13
+
14
+ const BINARY_NAME = 'snpm';
15
+ const REPO_OWNER = 'binbandit';
16
+ const REPO_NAME = 'snpm';
17
+
18
+ function getPlatform() {
19
+ const platform = process.platform;
20
+ const arch = process.arch;
21
+
22
+ const platformMap = {
23
+ darwin: {
24
+ x64: 'snpm-macos-amd64',
25
+ arm64: 'snpm-macos-arm64',
26
+ },
27
+ linux: {
28
+ x64: 'snpm-linux-amd64',
29
+ arm64: 'snpm-linux-arm64',
30
+ },
31
+ win32: {
32
+ x64: 'snpm-windows-amd64',
33
+ arm64: 'snpm-windows-arm64',
34
+ },
35
+ };
36
+
37
+ if (!platformMap[platform]) {
38
+ throw new Error(`Unsupported platform: ${platform}`);
39
+ }
40
+
41
+ if (!platformMap[platform][arch]) {
42
+ throw new Error(`Unsupported architecture: ${arch} on ${platform}`);
43
+ }
44
+
45
+ return platformMap[platform][arch];
46
+ }
47
+
48
+ function getDownloadUrl(version) {
49
+ const platform = getPlatform();
50
+ const isWindows = process.platform === 'win32';
51
+ const ext = isWindows ? 'zip' : 'tar.gz';
52
+
53
+ // Use the version from package.json or fetch latest
54
+ const tag = version || 'latest';
55
+
56
+ if (tag === 'latest') {
57
+ return `https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/latest/download/${platform}.${ext}`;
58
+ }
59
+
60
+ return `https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${tag}/${platform}.${ext}`;
61
+ }
62
+
63
+ async function download(url, dest) {
64
+ return new Promise((resolve, reject) => {
65
+ get(url, (response) => {
66
+ if (response.statusCode === 302 || response.statusCode === 301) {
67
+ // Follow redirect
68
+ download(response.headers.location, dest).then(resolve).catch(reject);
69
+ return;
70
+ }
71
+
72
+ if (response.statusCode !== 200) {
73
+ reject(new Error(`Failed to download: ${response.statusCode} ${response.statusMessage}`));
74
+ return;
75
+ }
76
+
77
+ const file = createWriteStream(dest);
78
+ response.pipe(file);
79
+ file.on('finish', () => {
80
+ file.close(resolve);
81
+ });
82
+ file.on('error', (err) => {
83
+ reject(err);
84
+ });
85
+ }).on('error', reject);
86
+ });
87
+ }
88
+
89
+ async function extractTarGz(archivePath, destDir) {
90
+ await tar.extract({
91
+ file: archivePath,
92
+ cwd: destDir,
93
+ });
94
+ }
95
+
96
+ async function extractZip(archivePath, destDir) {
97
+ const AdmZip = require('adm-zip');
98
+ const zip = new AdmZip(archivePath);
99
+ zip.extractAllTo(destDir, true);
100
+ }
101
+
102
+ async function install() {
103
+ try {
104
+ const binDir = join(__dirname, '..', 'bin');
105
+ const version = process.env.npm_package_version;
106
+
107
+ console.log(`Installing snpm ${version || 'latest'}...`);
108
+
109
+ // Create bin directory if it doesn't exist
110
+ if (!existsSync(binDir)) {
111
+ mkdirSync(binDir, { recursive: true });
112
+ }
113
+
114
+ const platform = getPlatform();
115
+ const isWindows = process.platform === 'win32';
116
+ const ext = isWindows ? 'zip' : 'tar.gz';
117
+ const archivePath = join(binDir, `${platform}.${ext}`);
118
+ const url = getDownloadUrl(version);
119
+
120
+ console.log(`Downloading from: ${url}`);
121
+ await download(url, archivePath);
122
+ console.log('Download complete, extracting...');
123
+
124
+ if (isWindows) {
125
+ await extractZip(archivePath, binDir);
126
+ } else {
127
+ await extractTarGz(archivePath, binDir);
128
+ }
129
+
130
+ // Make binary executable on Unix-like systems
131
+ if (!isWindows) {
132
+ const binaryPath = join(binDir, BINARY_NAME);
133
+ if (existsSync(binaryPath)) {
134
+ chmodSync(binaryPath, 0o755);
135
+ }
136
+ }
137
+
138
+ // Clean up archive
139
+ const fs = require('fs');
140
+ fs.unlinkSync(archivePath);
141
+
142
+ console.log('✓ snpm installed successfully!');
143
+ } catch (error) {
144
+ console.error('Failed to install snpm:', error.message);
145
+ console.error('You can manually download snpm from:');
146
+ console.error(`https://github.com/${REPO_OWNER}/${REPO_NAME}/releases`);
147
+ process.exit(1);
148
+ }
149
+ }
150
+
151
+ install();
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require('child_process');
4
+ const { join } = require('path');
5
+
6
+ const binPath = join(__dirname, '..', 'bin', process.platform === 'win32' ? 'snpm.exe' : 'snpm');
7
+
8
+ const result = spawnSync(binPath, ['--version'], {
9
+ stdio: 'inherit',
10
+ });
11
+
12
+ process.exit(result.status);