@ihason/rust-portable-win32-x64 0.0.0-stage → 1.99.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.
package/README.md CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # @ihason/rust-portable-win32-x64
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.99.1 toolchain for Windows 10/11 x64.
4
+
5
+ This package does not download anything from the network. It joins the data
6
+ chunks installed from npm, verifies the SHA256 of the archive, and extracts it
7
+ to `%LOCALAPPDATA%\rust-portable\1.99.1`. Override the location with
8
+ `RUST_PORTABLE_HOME`; the path must not contain spaces.
9
+
10
+ After installation:
11
+
12
+ 1. Run `<install dir>\windows\configure-env.bat`.
13
+ 2. Open a new terminal.
14
+ 3. Run `<install dir>\windows\doctor.bat`.
15
+
16
+ If the `postinstall` script was skipped (for example with `--ignore-scripts`),
17
+ run the installer manually:
18
+
19
+ ```powershell
20
+ node node_modules/@ihason/rust-portable-win32-x64/install.js
21
+ ```
22
+
23
+ The bundle contains third-party toolchains with their own licenses. See
24
+ `shared/licenses/` and `shared/THIRD-PARTY-NOTICES.md` in the installed bundle.
package/archive.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "zip": "rust-portable-v1.99.1-windows-x64.zip",
3
+ "size": 611000377,
4
+ "sha256": "4919731198a63585d6f50ac5e8c2a6c48cc62b1cc80bf3b267e4cad2c1375b83",
5
+ "parts": [
6
+ {
7
+ "package": "@ihason/rust-portable-win32-x64-chunk-01",
8
+ "file": "part01",
9
+ "bytes": 104857600
10
+ },
11
+ {
12
+ "package": "@ihason/rust-portable-win32-x64-chunk-02",
13
+ "file": "part02",
14
+ "bytes": 104857600
15
+ },
16
+ {
17
+ "package": "@ihason/rust-portable-win32-x64-chunk-03",
18
+ "file": "part03",
19
+ "bytes": 104857600
20
+ },
21
+ {
22
+ "package": "@ihason/rust-portable-win32-x64-chunk-04",
23
+ "file": "part04",
24
+ "bytes": 104857600
25
+ },
26
+ {
27
+ "package": "@ihason/rust-portable-win32-x64-chunk-05",
28
+ "file": "part05",
29
+ "bytes": 104857600
30
+ },
31
+ {
32
+ "package": "@ihason/rust-portable-win32-x64-chunk-06",
33
+ "file": "part06",
34
+ "bytes": 86712377
35
+ }
36
+ ]
37
+ }
package/install.js ADDED
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Joins the npm data chunks, verifies the resulting ZIP, and extracts the
5
+ // portable Rust toolchain into a directory without spaces.
6
+
7
+ const fs = require('node:fs');
8
+ const os = require('node:os');
9
+ const path = require('node:path');
10
+ const crypto = require('node:crypto');
11
+ const { execFileSync } = require('node:child_process');
12
+ const { createRequire } = require('node:module');
13
+ const { pipeline } = require('node:stream/promises');
14
+ const { Transform } = require('node:stream');
15
+
16
+ const archive = require('./archive.json');
17
+ const pkg = require('./package.json');
18
+ const requireFromHere = createRequire(__filename);
19
+
20
+ function log(message) {
21
+ console.log(`[rust-portable] ${message}`);
22
+ }
23
+
24
+ function fail(message) {
25
+ console.error(`[rust-portable] ${message}`);
26
+ process.exitCode = 1;
27
+ throw new Error(message);
28
+ }
29
+
30
+ function isComplete(directory) {
31
+ return fs.existsSync(path.join(directory, 'windows', 'cargo', 'bin', 'cargo.exe'));
32
+ }
33
+
34
+ async function main() {
35
+ if (process.platform !== 'win32' || process.arch !== 'x64') {
36
+ fail(`Unsupported platform ${process.platform}/${process.arch}. This package supports Windows 10/11 x64 only.`);
37
+ }
38
+ if (!Array.isArray(archive.parts) || archive.parts.length === 0) {
39
+ fail('archive.json does not list any data chunks.');
40
+ }
41
+
42
+ const defaultHome = path.join(
43
+ process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'),
44
+ 'rust-portable'
45
+ );
46
+ const home = path.resolve(process.env.RUST_PORTABLE_HOME || defaultHome);
47
+ if (/\s/.test(home)) {
48
+ fail(`Install path contains spaces: ${home}\nSet RUST_PORTABLE_HOME to a path without spaces, for example C:\\rust-portable.`);
49
+ }
50
+
51
+ const destination = path.join(home, pkg.version);
52
+ const marker = path.join(destination, '.installed');
53
+
54
+ if (fs.existsSync(marker) && isComplete(destination)) {
55
+ log(`${pkg.version} is already installed at ${destination}`);
56
+ printNextSteps(destination);
57
+ return;
58
+ }
59
+
60
+ const temporaryZip = path.join(os.tmpdir(), `rust-portable-${pkg.version}-${process.pid}.zip`);
61
+ const staging = path.join(home, `.staging-${pkg.version}-${process.pid}`);
62
+ const hash = crypto.createHash('sha256');
63
+ let written = 0;
64
+
65
+ fs.mkdirSync(home, { recursive: true });
66
+ fs.rmSync(staging, { recursive: true, force: true });
67
+ fs.mkdirSync(staging, { recursive: true });
68
+ fs.writeFileSync(temporaryZip, '');
69
+
70
+ try {
71
+ for (const part of archive.parts) {
72
+ const packageJson = requireFromHere.resolve(`${part.package}/package.json`);
73
+ const partPath = path.join(path.dirname(packageJson), part.file);
74
+ if (!fs.existsSync(partPath)) {
75
+ fail(`Missing data chunk: ${partPath}`);
76
+ }
77
+ log(`Adding ${part.package}/${part.file}`);
78
+ const meter = new Transform({
79
+ transform(chunk, encoding, callback) {
80
+ hash.update(chunk);
81
+ written += chunk.length;
82
+ callback(null, chunk);
83
+ }
84
+ });
85
+ await pipeline(
86
+ fs.createReadStream(partPath),
87
+ meter,
88
+ fs.createWriteStream(temporaryZip, { flags: 'a' })
89
+ );
90
+ }
91
+
92
+ const actualHash = hash.digest('hex');
93
+ if (written !== archive.size || actualHash !== archive.sha256) {
94
+ fail(`Archive verification failed: ${written}/${archive.size} bytes, SHA256 ${actualHash}.`);
95
+ }
96
+ log(`Verified ${archive.zip} (${written} bytes, SHA256 ${actualHash})`);
97
+
98
+ const tar = path.join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'tar.exe');
99
+ if (!fs.existsSync(tar)) {
100
+ fail(`Windows tar.exe was not found at ${tar}. Windows 10 1803 or newer is required.`);
101
+ }
102
+
103
+ log(`Extracting to ${staging}`);
104
+ execFileSync(tar, ['-xf', temporaryZip, '-C', staging, '--strip-components=1'], {
105
+ stdio: 'inherit'
106
+ });
107
+
108
+ if (!isComplete(staging)) {
109
+ fail('Extraction finished but windows\\cargo\\bin\\cargo.exe is missing.');
110
+ }
111
+
112
+ if (fs.existsSync(destination)) {
113
+ if (isComplete(destination)) {
114
+ log(`${pkg.version} is already installed at ${destination}`);
115
+ printNextSteps(destination);
116
+ return;
117
+ }
118
+ if (process.env.RUST_PORTABLE_FORCE !== '1') {
119
+ fail(`Destination already exists and does not look complete: ${destination}\nRemove it, or set RUST_PORTABLE_FORCE=1 to replace it.`);
120
+ }
121
+ fs.rmSync(destination, { recursive: true, force: true });
122
+ }
123
+
124
+ fs.renameSync(staging, destination);
125
+ fs.writeFileSync(marker, `${archive.sha256}\n`);
126
+ log(`Installed to ${destination}`);
127
+ log('The npm data chunks remain in node_modules; remove that project\'s node_modules to reclaim the space.');
128
+ printNextSteps(destination);
129
+ } finally {
130
+ fs.rmSync(temporaryZip, { force: true });
131
+ fs.rmSync(staging, { recursive: true, force: true });
132
+ }
133
+ }
134
+
135
+ function printNextSteps(destination) {
136
+ const windows = path.join(destination, 'windows');
137
+ console.log('');
138
+ log('Next steps:');
139
+ log(` 1. Run "${path.join(windows, 'configure-env.bat')}"`);
140
+ log(' 2. Open a new terminal');
141
+ log(` 3. Run "${path.join(windows, 'doctor.bat')}"`);
142
+ }
143
+
144
+ main().catch((error) => {
145
+ if (!process.exitCode) {
146
+ console.error(error.stack || String(error));
147
+ process.exitCode = 1;
148
+ }
149
+ });
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@ihason/rust-portable-win32-x64",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.99.1",
4
+ "description": "Portable Rust 1.99.1 toolchain for Windows x64",
5
+ "keywords": [
6
+ "rust",
7
+ "toolchain",
8
+ "portable",
9
+ "windows",
10
+ "mingw"
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
+ "os": [
23
+ "win32"
24
+ ],
25
+ "cpu": [
26
+ "x64"
27
+ ],
28
+ "files": [
29
+ "install.js",
30
+ "archive.json",
31
+ "README.md"
32
+ ],
33
+ "bin": {
34
+ "rust-portable-install": "install.js"
35
+ },
36
+ "scripts": {
37
+ "postinstall": "node install.js"
38
+ },
39
+ "dependencies": {
40
+ "@ihason/rust-portable-win32-x64-chunk-01": "1.99.1",
41
+ "@ihason/rust-portable-win32-x64-chunk-02": "1.99.1",
42
+ "@ihason/rust-portable-win32-x64-chunk-03": "1.99.1",
43
+ "@ihason/rust-portable-win32-x64-chunk-04": "1.99.1",
44
+ "@ihason/rust-portable-win32-x64-chunk-05": "1.99.1",
45
+ "@ihason/rust-portable-win32-x64-chunk-06": "1.99.1"
46
+ },
47
+ "engines": {
48
+ "node": ">=18"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ }
53
+ }