@ihason/rust-portable 1.99.1 → 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.
- package/README.md +36 -6
- package/cli.js +81 -0
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
1
|
# @ihason/rust-portable
|
|
2
2
|
|
|
3
|
-
Portable Rust 1.
|
|
3
|
+
Portable Rust 1.100.0 toolchain.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Supported platforms:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
9
15
|
```
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
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,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ihason/rust-portable",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Portable Rust 1.
|
|
3
|
+
"version": "1.100.0",
|
|
4
|
+
"description": "Portable Rust 1.100.0 toolchain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rust",
|
|
7
7
|
"toolchain",
|
|
8
8
|
"portable",
|
|
9
9
|
"windows",
|
|
10
|
-
"
|
|
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.
|
|
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"
|
|
27
33
|
},
|
|
28
34
|
"engines": {
|
|
29
35
|
"node": ">=18"
|