@asamarts/alint 0.16.1 → 0.18.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 +2 -2
  2. package/install.js +35 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -23,7 +23,7 @@ alint check
23
23
  ```
24
24
 
25
25
  The npm package version tracks alint releases exactly: `npm install
26
- @asamarts/alint@0.16.1` downloads alint v0.16.1.
26
+ @asamarts/alint@0.18.0` downloads alint v0.18.0.
27
27
 
28
28
  ## Supported platforms
29
29
 
@@ -31,7 +31,7 @@ The npm package version tracks alint releases exactly: `npm install
31
31
  |---------|----------------------|
32
32
  | Linux | x64, arm64 (musl) |
33
33
  | macOS | x64, arm64 |
34
- | Windows | x64 |
34
+ | Windows | x64 (arm64 runs the x64 binary under Windows 11 emulation) |
35
35
 
36
36
  For unsupported platforms, install via `cargo install alint`,
37
37
  [Homebrew](https://github.com/asamarts/alint#homebrew-macos--linuxbrew), or by
package/install.js CHANGED
@@ -21,7 +21,6 @@ const path = require('path');
21
21
  const https = require('https');
22
22
  const crypto = require('crypto');
23
23
  const os = require('os');
24
- const tar = require('tar');
25
24
 
26
25
  const REPO = 'asamarts/alint';
27
26
  const PKG_VERSION = require('./package.json').version;
@@ -46,16 +45,24 @@ function shouldSkip() {
46
45
 
47
46
  // Map Node platform/arch to the alint release-target triple.
48
47
  // The list mirrors install.sh and the release.yml build matrix.
49
- function resolveTarget() {
50
- const platform = process.platform;
51
- const arch = process.arch;
52
- const map = {
53
- 'linux/x64': 'x86_64-unknown-linux-musl',
54
- 'linux/arm64': 'aarch64-unknown-linux-musl',
55
- 'darwin/x64': 'x86_64-apple-darwin',
56
- 'darwin/arm64': 'aarch64-apple-darwin',
57
- 'win32/x64': 'x86_64-pc-windows-msvc',
58
- };
48
+ // package.json's `os` x `cpu` admits every combination of these keys, so
49
+ // each one MUST map to a target the release actually builds
50
+ // (ci/scripts/test-npm-shim.sh enforces both directions).
51
+ //
52
+ // win32/arm64: there is no native Windows-on-ARM build. Windows 11 on ARM
53
+ // runs x64 binaries under its built-in emulation, so ship the x64 binary
54
+ // rather than fail the postinstall outright.
55
+ const TARGETS = {
56
+ 'linux/x64': 'x86_64-unknown-linux-musl',
57
+ 'linux/arm64': 'aarch64-unknown-linux-musl',
58
+ 'darwin/x64': 'x86_64-apple-darwin',
59
+ 'darwin/arm64': 'aarch64-apple-darwin',
60
+ 'win32/x64': 'x86_64-pc-windows-msvc',
61
+ 'win32/arm64': 'x86_64-pc-windows-msvc',
62
+ };
63
+
64
+ function resolveTarget(platform = process.platform, arch = process.arch) {
65
+ const map = TARGETS;
59
66
  const key = `${platform}/${arch}`;
60
67
  const target = map[key];
61
68
  if (!target) {
@@ -111,6 +118,12 @@ async function main() {
111
118
  }
112
119
 
113
120
  const target = resolveTarget();
121
+ if (process.platform === 'win32' && process.arch === 'arm64') {
122
+ process.stderr.write(
123
+ '@asamarts/alint: no native Windows-on-ARM build; installing the x64 binary ' +
124
+ '(runs under Windows 11 x64 emulation)\n',
125
+ );
126
+ }
114
127
  const archive = `alint-${VERSION_TAG}-${target}.tar.gz`;
115
128
  const baseUrl = `https://github.com/${REPO}/releases/download/${VERSION_TAG}`;
116
129
  const tarUrl = `${baseUrl}/${archive}`;
@@ -141,6 +154,9 @@ async function main() {
141
154
  // Tarball layout: alint-<tag>-<target>/alint (or alint.exe).
142
155
  // We extract the whole thing under tmp, then move just the
143
156
  // binary into ./bin-platform/.
157
+ // Required lazily so the target table can be unit-tested without
158
+ // node_modules (ci/scripts/test-npm-shim.sh).
159
+ const tar = require('tar');
144
160
  await tar.x({ file: tarPath, cwd: tmpDir });
145
161
  const isWindows = process.platform === 'win32';
146
162
  const binaryName = isWindows ? 'alint.exe' : 'alint';
@@ -170,7 +186,11 @@ async function main() {
170
186
  process.stderr.write(`@asamarts/alint: installed ${binaryName} for ${target}\n`);
171
187
  }
172
188
 
173
- main().catch((err) => {
174
- process.stderr.write(`@asamarts/alint: postinstall failed: ${err.message}\n`);
175
- process.exit(1);
176
- });
189
+ module.exports = { TARGETS, resolveTarget };
190
+
191
+ if (require.main === module) {
192
+ main().catch((err) => {
193
+ process.stderr.write(`@asamarts/alint: postinstall failed: ${err.message}\n`);
194
+ process.exit(1);
195
+ });
196
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asamarts/alint",
3
- "version": "0.16.1",
3
+ "version": "0.18.0",
4
4
  "description": "Language-agnostic linter for repository structure, file existence, filename conventions, and file content rules. This package downloads and wraps the platform-matched native alint binary.",
5
5
  "keywords": [
6
6
  "lint",