tiefrun 1.0.0 → 1.0.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/bin/tiefrun.js CHANGED
@@ -1,37 +1,35 @@
1
1
  #!/usr/bin/env node
2
+ // TR-33: resolve the per-platform package npm installed for this host (each
3
+ // sub-package is os/cpu-gated, so only one is present) and exec its binary as
4
+ // `tiefrun` (argv0) so --help/usage shows the right program name.
2
5
  const { spawn } = require('child_process');
3
6
  const path = require('path');
4
- const os = require('os');
5
- const fs = require('fs');
6
7
 
7
- function selectBinary() {
8
- const platform = os.platform(); // 'darwin' | 'linux' | 'win32'
9
- const arch = os.arch(); // 'x64' | 'arm64' | ...
10
- let name;
11
- if (platform === 'win32') {
12
- name = 'tiefrun-win32-x64.exe';
13
- } else if (platform === 'darwin') {
14
- name = arch === 'arm64' ? 'tiefrun-darwin-arm64' : 'tiefrun-darwin-x64';
15
- } else if (platform === 'linux') {
16
- name = arch === 'arm64' ? 'tiefrun-linux-arm64' : 'tiefrun-linux-x64';
17
- } else {
18
- throw new Error(`Unsupported platform: ${platform}/${arch}`);
19
- }
20
- const p = path.join(__dirname, name);
21
- if (!fs.existsSync(p)) {
8
+ function binaryPath() {
9
+ const platform = process.platform; // darwin | linux | win32
10
+ const arch = process.arch; // x64 | arm64
11
+ const pkg = `@microrapid/tiefrun-${platform}-${arch}`;
12
+ const exe = platform === 'win32' ? 'tiefrun.exe' : 'tiefrun';
13
+ let pkgJson;
14
+ try {
15
+ pkgJson = require.resolve(`${pkg}/package.json`);
16
+ } catch (e) {
22
17
  throw new Error(
23
- `No prebuilt tiefrun binary for ${platform}/${arch} (${name}). ` +
24
- `Download one from https://github.com/microrapids/api-runtime/releases`
18
+ `Missing platform package '${pkg}'. Reinstall tiefrun with optional ` +
19
+ `dependencies enabled (npm install --include=optional), or download a ` +
20
+ `binary from https://github.com/microrapids/api-runtime/releases`
25
21
  );
26
22
  }
27
- return p;
23
+ return path.join(path.dirname(pkgJson), 'bin', exe);
28
24
  }
29
25
 
30
26
  try {
31
- const binary = selectBinary();
32
- const child = spawn(binary, process.argv.slice(2), { stdio: 'inherit' });
27
+ const child = spawn(binaryPath(), process.argv.slice(2), { stdio: 'inherit', argv0: 'tiefrun' });
33
28
  child.on('error', (err) => { console.error('tiefrun:', err.message); process.exit(1); });
34
- child.on('exit', (code) => process.exit(code === null ? 1 : code));
29
+ child.on('exit', (code, signal) => {
30
+ if (signal) process.kill(process.pid, signal);
31
+ else process.exit(code === null ? 1 : code);
32
+ });
35
33
  } catch (err) {
36
34
  console.error('tiefrun:', err.message);
37
35
  process.exit(1);
package/package.json CHANGED
@@ -1,21 +1,19 @@
1
1
  {
2
2
  "name": "tiefrun",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MicroRapids API Runtime - executable OpenAPI specifications",
5
- "bin": {
6
- "tiefrun": "./bin/tiefrun.js"
7
- },
5
+ "bin": { "tiefrun": "./bin/tiefrun.js" },
8
6
  "files": ["bin/**/*"],
9
- "os": ["darwin", "linux", "win32"],
10
- "cpu": ["x64", "arm64"],
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/microrapids/api-runtime.git"
7
+ "optionalDependencies": {
8
+ "@microrapid/tiefrun-linux-x64": "1.0.1",
9
+ "@microrapid/tiefrun-linux-arm64": "1.0.1",
10
+ "@microrapid/tiefrun-darwin-x64": "1.0.1",
11
+ "@microrapid/tiefrun-darwin-arm64": "1.0.1",
12
+ "@microrapid/tiefrun-win32-x64": "1.0.1"
14
13
  },
14
+ "repository": { "type": "git", "url": "https://github.com/microrapids/api-runtime.git" },
15
15
  "keywords": ["cli", "api", "openapi", "testing", "rest", "graphql"],
16
16
  "author": "MicroRapids Team",
17
17
  "license": "MIT",
18
- "engines": {
19
- "node": ">=14.0.0"
20
- }
18
+ "engines": { "node": ">=14.0.0" }
21
19
  }
Binary file
Binary file
Binary file
Binary file
Binary file