layero 0.1.5 → 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.5",
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,28 +1,32 @@
1
1
  #!/usr/bin/env node
2
2
  // Print a quick-start banner after `npm install -g layero`.
3
- // Stays silent in CI, in non-TTY (piped/automated installs), and when
4
- // installed as a transitive dependency.
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.
5
11
 
6
12
  if (process.env.CI) return;
7
13
  if (process.env.LAYERO_SKIP_POSTINSTALL) return;
8
- if (!process.stdout.isTTY) return;
9
14
 
10
- // Only print when the user installed `layero` directly (not as a sub-dep).
11
- // npm sets npm_config_global=true for `npm install -g`; for local installs
12
- // we check that this package is the install target via npm_package_name.
15
+ // Only print when `layero` is the install target not when it's pulled
16
+ // in as a transitive dep of another package.
13
17
  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
- const c = process.stdout.hasColors && process.stdout.hasColors()
18
- ? {
19
- reset: "\x1b[0m",
20
- bold: "\x1b[1m",
21
- dim: "\x1b[2m",
22
- cyan: "\x1b[36m",
23
- green: "\x1b[32m",
24
- }
25
- : { 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
+ };
26
30
 
27
31
  const lines = [
28
32
  "",
@@ -35,4 +39,17 @@ const lines = [
35
39
  ` ${c.dim}Docs: https://layero.ru${c.reset}`,
36
40
  "",
37
41
  ];
38
- process.stdout.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
+ }