@ihason/rust-portable 0.0.0-stage → 1.100.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.
Files changed (3) hide show
  1. package/README.md +41 -2
  2. package/cli.js +81 -0
  3. package/package.json +38 -4
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # @ihason/rust-portable
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Portable Rust 1.100.0 toolchain.
4
+
5
+ Supported platforms:
6
+
7
+ - Windows x64: `@ihason/rust-portable-win32-x64`
8
+ - Linux x64: `@ihason/rust-portable-linux-x64`
9
+ - Linux arm64: `@ihason/rust-portable-linux-arm64`
10
+
11
+ Install with npx:
12
+
13
+ ```bash
14
+ npx @ihason/rust-portable setup
15
+ ```
16
+
17
+ The setup command is interactive. It asks for the install location, PATH
18
+ configuration and self-check. Press Enter to accept the recommended values.
19
+ Run `npx @ihason/rust-portable setup --help` for all options.
20
+
21
+ All data comes from the npm chunk packages. Setup does not use GitHub.
22
+
23
+ Windows:
24
+
25
+ - The toolchain is extracted to a directory. No system installation.
26
+ - The path must not contain spaces.
27
+ - Setup can run `configure-env.bat` and `doctor.bat`.
28
+
29
+ Linux:
30
+
31
+ - User-level install: default for a normal user.
32
+ - System-level install: `--system` uses sudo.
33
+ - The install prefix must be absolute and must not contain spaces.
34
+ - Setup can install missing system tools and run `doctor.sh`.
35
+
36
+ `npm install` also works. Its postinstall script extracts the bundle to
37
+ `rust-portable` in the directory where npm was run. Run `linux/install.sh`
38
+ on Linux after extraction.
39
+
40
+ Do not use `--omit=optional`, `--no-optional` or `--ignore-scripts`.
41
+
42
+ Documentation: <https://github.com/HasonHuang/rust-portable/blob/main/docs/NPM.md>
package/cli.js ADDED
@@ -0,0 +1,81 @@
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.'
71
+ );
72
+ }
73
+
74
+ const result = spawnSync(process.execPath, [setupPath, ...args.slice(1)], {
75
+ stdio: 'inherit'
76
+ });
77
+
78
+ if (result.error) {
79
+ fail(`cannot run setup: ${result.error.message}`);
80
+ }
81
+ process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@ihason/rust-portable",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.100.0",
4
+ "description": "Portable Rust 1.100.0 toolchain",
5
+ "keywords": [
6
+ "rust",
7
+ "toolchain",
8
+ "portable",
9
+ "windows",
10
+ "linux"
11
+ ],
12
+ "homepage": "https://github.com/HasonHuang/rust-portable#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/HasonHuang/rust-portable/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/HasonHuang/rust-portable.git"
19
+ },
20
+ "author": "Hason Huang",
21
+ "license": "MIT",
22
+ "bin": {
23
+ "rust-portable": "cli.js"
24
+ },
25
+ "files": [
26
+ "cli.js",
27
+ "README.md"
28
+ ],
29
+ "optionalDependencies": {
30
+ "@ihason/rust-portable-win32-x64": "1.100.0",
31
+ "@ihason/rust-portable-linux-x64": "1.100.0",
32
+ "@ihason/rust-portable-linux-arm64": "1.100.0"
33
+ },
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ }
40
+ }