layero 0.1.6 → 0.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "layero",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Layero CLI — publish a local site with one command.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,9 +1,13 @@
1
1
  #!/usr/bin/env node
2
- // Print a quick-start banner after `npm install -g layero`. We write to
3
- // stderr because npm 10+ buffers postinstall stdout by default
4
- // (`foreground-scripts=false`) and only surfaces it on script failure —
5
- // stderr is passed through verbatim, which is how other CLIs (vite,
6
- // cypress, etc.) deliver post-install messages.
2
+ // Print a quick-start banner after `npm install -g layero`.
3
+ //
4
+ // npm 10+ buffers postinstall stdout AND stderr (foreground-scripts=false
5
+ // by default), so writing to either is invisible unless the script fails
6
+ // or the user passes --foreground-scripts. Workaround: write directly to
7
+ // the controlling terminal at /dev/tty, which bypasses npm's pipe.
8
+ //
9
+ // On Windows there's no /dev/tty; we fall back to stderr (which Windows
10
+ // npm doesn't buffer the same way) and silently skip on any error.
7
11
 
8
12
  if (process.env.CI) return;
9
13
  if (process.env.LAYERO_SKIP_POSTINSTALL) return;
@@ -14,17 +18,15 @@ const isGlobal = process.env.npm_config_global === "true";
14
18
  const isDirect = process.env.npm_package_name === "layero";
15
19
  if (!isGlobal && !isDirect) return;
16
20
 
17
- // Best-effort color: stderr is usually a TTY, but stay safe.
18
- const useColor = process.stderr.isTTY && (process.stderr.hasColors?.() ?? true);
19
- const c = useColor
20
- ? {
21
- reset: "\x1b[0m",
22
- bold: "\x1b[1m",
23
- dim: "\x1b[2m",
24
- cyan: "\x1b[36m",
25
- green: "\x1b[32m",
26
- }
27
- : { reset: "", bold: "", dim: "", cyan: "", green: "" };
21
+ const fs = require("node:fs");
22
+
23
+ const c = {
24
+ reset: "\x1b[0m",
25
+ bold: "\x1b[1m",
26
+ dim: "\x1b[2m",
27
+ cyan: "\x1b[36m",
28
+ green: "\x1b[32m",
29
+ };
28
30
 
29
31
  const lines = [
30
32
  "",
@@ -37,4 +39,17 @@ const lines = [
37
39
  ` ${c.dim}Docs: https://layero.ru${c.reset}`,
38
40
  "",
39
41
  ];
40
- process.stderr.write(lines.join("\n"));
42
+ const banner = lines.join("\n");
43
+
44
+ try {
45
+ if (process.platform === "win32") {
46
+ process.stderr.write(banner);
47
+ } else {
48
+ // Open the controlling tty directly. This bypasses npm's stdio pipes.
49
+ const fd = fs.openSync("/dev/tty", "w");
50
+ fs.writeSync(fd, banner);
51
+ fs.closeSync(fd);
52
+ }
53
+ } catch {
54
+ // Headless install (no tty), or perms issue — give up silently.
55
+ }