@ihason/rust-portable 1.99.1 → 1.100.1-r2

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/README.md +38 -6
  2. package/cli.js +84 -0
  3. package/package.json +10 -4
package/README.md CHANGED
@@ -1,12 +1,44 @@
1
1
  # @ihason/rust-portable
2
2
 
3
- Portable Rust 1.99.1 toolchain.
3
+ Portable Rust 1.100.1 toolchain.
4
4
 
5
- This package currently supports Windows 10/11 x64 only:
5
+ Release 1.100.1-r2.
6
6
 
7
- ```powershell
8
- npm install @ihason/rust-portable
7
+ Supported platforms:
8
+
9
+ - Windows x64: `@ihason/rust-portable-win32-x64`
10
+ - Linux x64: `@ihason/rust-portable-linux-x64`
11
+ - Linux arm64: `@ihason/rust-portable-linux-arm64`
12
+
13
+ Install with npx:
14
+
15
+ ```bash
16
+ npx @ihason/rust-portable setup
9
17
  ```
10
18
 
11
- On other platforms npm skips the platform package. See
12
- <https://github.com/HasonHuang/rust-portable> for documentation and licenses.
19
+ The setup command is interactive. It asks for the install location, PATH
20
+ configuration and self-check. Press Enter to accept the recommended values.
21
+ Run `npx @ihason/rust-portable setup --help` for all options.
22
+
23
+ All data comes from the npm chunk packages. Setup does not use GitHub.
24
+
25
+ Windows:
26
+
27
+ - The toolchain is extracted to a directory. No system installation.
28
+ - Paths with spaces are supported, for example `D:\Program Files\rust-portable`.
29
+ - Setup can run `configure-env.bat` and `doctor.bat`.
30
+
31
+ Linux:
32
+
33
+ - User-level install: default for a normal user.
34
+ - System-level install: `--system` uses sudo.
35
+ - The install prefix must be absolute and must not contain spaces.
36
+ - Setup can install missing system tools and run `doctor.sh`.
37
+
38
+ `npm install` also works. Its postinstall script extracts the bundle to
39
+ `rust-portable` in the directory where npm was run. Run `linux/install.sh`
40
+ on Linux after extraction.
41
+
42
+ Do not use `--omit=optional`, `--no-optional` or `--ignore-scripts`.
43
+
44
+ Documentation: <https://github.com/HasonHuang/rust-portable/blob/main/docs/NPM.md>
package/cli.js ADDED
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Entry point for @scope/rust-portable.
5
+ // It selects the platform package and runs its setup command.
6
+
7
+ const { spawnSync } = require('node:child_process');
8
+ const pkg = require('./package.json');
9
+
10
+ const args = process.argv.slice(2);
11
+ const command = args[0];
12
+
13
+ function usage() {
14
+ console.log(`Usage: rust-portable <command>
15
+
16
+ Commands:
17
+ setup Install the portable Rust toolchain. Interactive by default.
18
+ version Show the package version.
19
+ help Show this help.
20
+
21
+ Examples:
22
+ npx ${pkg.name} setup
23
+ npx ${pkg.name} setup --non-interactive
24
+ npx ${pkg.name} setup --help`);
25
+ }
26
+
27
+ function fail(message) {
28
+ console.error(`[rust-portable] ERROR: ${message}`);
29
+ process.exit(1);
30
+ }
31
+
32
+ if (!command || command === 'help' || command === '--help' || command === '-h') {
33
+ usage();
34
+ process.exit(0);
35
+ }
36
+
37
+ if (command === 'version' || command === '--version' || command === '-v') {
38
+ console.log(pkg.version);
39
+ process.exit(0);
40
+ }
41
+
42
+ if (command !== 'setup') {
43
+ console.error(`[rust-portable] ERROR: unknown command: ${command}`);
44
+ usage();
45
+ process.exit(1);
46
+ }
47
+
48
+ if (process.platform === 'linux' && typeof process.getuid === 'function'
49
+ && process.getuid() === 0 && process.env.SUDO_USER) {
50
+ fail('Do not run npx with sudo. Run npx as your user; setup uses sudo when needed.');
51
+ }
52
+
53
+ const key = `${process.platform}-${process.arch}`;
54
+ const optional = pkg.optionalDependencies || {};
55
+ const platformPackage = Object.keys(optional).find((name) => name.endsWith(`-${key}`));
56
+
57
+ if (!platformPackage) {
58
+ const supported = Object.keys(optional)
59
+ .map((name) => name.slice(name.lastIndexOf('rust-portable-') + 'rust-portable-'.length))
60
+ .join(', ');
61
+ fail(`unsupported platform: ${key}. Supported platforms: ${supported}.`);
62
+ }
63
+
64
+ let setupPath;
65
+ try {
66
+ setupPath = require.resolve(`${platformPackage}/setup.js`);
67
+ } catch {
68
+ fail(
69
+ `the platform package ${platformPackage} is not installed.\n` +
70
+ 'Do not use --omit=optional, --no-optional or --ignore-scripts.\n' +
71
+ 'If an earlier install failed, clear the npx cache and run setup again:\n' +
72
+ ' Linux/macOS: rm -rf ~/.npm/_npx\n' +
73
+ ' Windows: Remove-Item -Recurse -Force "$env:LOCALAPPDATA\\npm-cache\\_npx"'
74
+ );
75
+ }
76
+
77
+ const result = spawnSync(process.execPath, [setupPath, ...args.slice(1)], {
78
+ stdio: 'inherit'
79
+ });
80
+
81
+ if (result.error) {
82
+ fail(`cannot run setup: ${result.error.message}`);
83
+ }
84
+ process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@ihason/rust-portable",
3
- "version": "1.99.1",
4
- "description": "Portable Rust 1.99.1 toolchain",
3
+ "version": "1.100.1-r2",
4
+ "description": "Portable Rust 1.100.1 toolchain",
5
5
  "keywords": [
6
6
  "rust",
7
7
  "toolchain",
8
8
  "portable",
9
9
  "windows",
10
- "mingw"
10
+ "linux"
11
11
  ],
12
12
  "homepage": "https://github.com/HasonHuang/rust-portable#readme",
13
13
  "bugs": {
@@ -19,11 +19,17 @@
19
19
  },
20
20
  "author": "Hason Huang",
21
21
  "license": "MIT",
22
+ "bin": {
23
+ "rust-portable": "cli.js"
24
+ },
22
25
  "files": [
26
+ "cli.js",
23
27
  "README.md"
24
28
  ],
25
29
  "optionalDependencies": {
26
- "@ihason/rust-portable-win32-x64": "1.99.1"
30
+ "@ihason/rust-portable-win32-x64": "1.100.1-r2",
31
+ "@ihason/rust-portable-linux-x64": "1.100.1-r2",
32
+ "@ihason/rust-portable-linux-arm64": "1.100.1-r2"
27
33
  },
28
34
  "engines": {
29
35
  "node": ">=18"