@kubbisec/naus 1.0.5 → 1.0.6

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 (2) hide show
  1. package/bin/naus.js +7 -40
  2. package/package.json +5 -5
package/bin/naus.js CHANGED
@@ -1,24 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- /**
4
- * @kubbisec/naus — Launcher mínimo
5
- *
6
- * Detecta a plataforma e arquitetura do host, resolve o pacote de plataforma
7
- * correspondente instalado via optionalDependencies e executa o binário nativo.
8
- *
9
- * Não depende de postinstall scripts. Funciona com --ignore-scripts=true.
10
- */
11
-
12
3
  "use strict";
13
4
 
14
- const { execFileSync, spawn } = require("child_process");
5
+ const { spawn } = require("child_process");
15
6
  const path = require("path");
16
7
  const fs = require("fs");
17
8
 
18
- // ---------------------------------------------------------------------------
19
- // Mapeamento de plataforma + arch → nome do pacote npm
20
- // ---------------------------------------------------------------------------
21
-
22
9
  const PLATFORM_MAP = {
23
10
  "linux-x64": "@kubbisec/naus-linux-x64",
24
11
  "linux-arm64": "@kubbisec/naus-linux-arm64",
@@ -31,23 +18,18 @@ const packageName = PLATFORM_MAP[platformKey];
31
18
 
32
19
  if (!packageName) {
33
20
  console.error(
34
- `[naus] Plataforma não suportada: ${process.platform}/${process.arch}\n` +
35
- `Plataformas suportadas: ${Object.keys(PLATFORM_MAP)
21
+ `[naus] Unsupported platform: ${process.platform}/${process.arch}\n` +
22
+ `Supported: ${Object.keys(PLATFORM_MAP)
36
23
  .map((k) => k.replace("-", "/"))
37
24
  .join(", ")}`
38
25
  );
39
26
  process.exit(1);
40
27
  }
41
28
 
42
- // ---------------------------------------------------------------------------
43
- // Resolver caminho do binário nativo
44
- // ---------------------------------------------------------------------------
45
-
46
29
  const binaryName = process.platform === "win32" ? "naus.exe" : "naus";
47
30
 
48
31
  let binaryPath = null;
49
32
 
50
- // Estratégia 1: require.resolve do pacote de plataforma
51
33
  try {
52
34
  const pkgDir = path.dirname(
53
35
  require.resolve(`${packageName}/package.json`)
@@ -57,15 +39,11 @@ try {
57
39
  binaryPath = candidate;
58
40
  }
59
41
  } catch {
60
- // pacote não encontrado via require.resolve
61
42
  }
62
43
 
63
- // Estratégia 2: busca relativa (quando instalado globalmente com npm)
64
44
  if (!binaryPath) {
65
45
  const globalSearchPaths = [
66
- // npm global: node_modules ao lado deste pacote
67
46
  path.resolve(__dirname, "..", "..", packageName, "bin", binaryName),
68
- // pnpm global: node_modules/.pnpm/<pkg>/node_modules/<pkg>/bin
69
47
  path.resolve(
70
48
  __dirname,
71
49
  "..",
@@ -85,41 +63,30 @@ if (!binaryPath) {
85
63
 
86
64
  if (!binaryPath) {
87
65
  console.error(
88
- `[naus] Binário nativo não encontrado para ${process.platform}/${process.arch}.\n` +
89
- `Pacote esperado: ${packageName}\n` +
90
- `Tente reinstalar: npm install -g @kubbisec/naus`
66
+ `[naus] Native binary not found for ${process.platform}/${process.arch}.\n` +
67
+ `Expected package: ${packageName}\n` +
68
+ `Try reinstalling: npm install -g @kubbisec/naus`
91
69
  );
92
70
  process.exit(1);
93
71
  }
94
72
 
95
- // ---------------------------------------------------------------------------
96
- // Garantir permissão de execução (Unix)
97
- // ---------------------------------------------------------------------------
98
-
99
73
  if (process.platform !== "win32") {
100
74
  try {
101
75
  fs.chmodSync(binaryPath, 0o755);
102
76
  } catch {
103
- // pode falhar se read-only; ignora
104
77
  }
105
78
  }
106
79
 
107
- // ---------------------------------------------------------------------------
108
- // Executar binário nativo herdando stdio, env e sinais
109
- // ---------------------------------------------------------------------------
110
-
111
80
  const child = spawn(binaryPath, process.argv.slice(2), {
112
81
  stdio: "inherit",
113
82
  env: process.env,
114
83
  windowsHide: true,
115
84
  });
116
85
 
117
- // Propagar sinais
118
86
  const forwardSignal = (signal) => {
119
87
  try {
120
88
  child.kill(signal);
121
89
  } catch {
122
- // processo já pode ter saído
123
90
  }
124
91
  };
125
92
 
@@ -127,7 +94,7 @@ process.on("SIGINT", () => forwardSignal("SIGINT"));
127
94
  process.on("SIGTERM", () => forwardSignal("SIGTERM"));
128
95
 
129
96
  child.on("error", (err) => {
130
- console.error(`[naus] Falha ao executar binário: ${err.message}`);
97
+ console.error(`[naus] Failed to execute binary: ${err.message}`);
131
98
  process.exit(1);
132
99
  });
133
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubbisec/naus",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "KubbiSec Naus CI/CD Runner — install globally, run anywhere",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -12,10 +12,10 @@
12
12
  "LICENSE"
13
13
  ],
14
14
  "optionalDependencies": {
15
- "@kubbisec/naus-linux-x64": "1.0.5",
16
- "@kubbisec/naus-linux-arm64": "1.0.5",
17
- "@kubbisec/naus-darwin-arm64": "1.0.5",
18
- "@kubbisec/naus-win32-x64": "1.0.5"
15
+ "@kubbisec/naus-linux-x64": "1.0.6",
16
+ "@kubbisec/naus-linux-arm64": "1.0.6",
17
+ "@kubbisec/naus-darwin-arm64": "1.0.6",
18
+ "@kubbisec/naus-win32-x64": "1.0.6"
19
19
  },
20
20
  "engines": {
21
21
  "node": ">=18"