plc-checkweigher 1.13.0 → 1.15.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.
- package/bin/cli.js +44 -24
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -47,10 +47,9 @@ function dotRows(word) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// ── TØVEX-SYSTEMS access banner ───────────────────────────────────────────────
|
|
50
|
-
function
|
|
51
|
-
const INNER = 52;
|
|
50
|
+
function buildBanner() {
|
|
51
|
+
const INNER = 52;
|
|
52
52
|
|
|
53
|
-
// Center a plain-text string inside INNER
|
|
54
53
|
function cen(str) {
|
|
55
54
|
const len = str.length;
|
|
56
55
|
const lpad = Math.floor((INNER - len) / 2);
|
|
@@ -67,29 +66,50 @@ function showAccessDenied() {
|
|
|
67
66
|
|
|
68
67
|
const tRow = dotRows('TØVEX');
|
|
69
68
|
const sRow = dotRows('SYSTEMS');
|
|
69
|
+
const sep = Array.from({ length: sRow[0].length }, (_, i) => i % 2 ? ' ' : '·').join('');
|
|
70
|
+
|
|
71
|
+
const lines = [
|
|
72
|
+
'',
|
|
73
|
+
`${B}╔${bar}╗${NC}`,
|
|
74
|
+
blank,
|
|
75
|
+
...tRow.map(r => boxRow(r, B)),
|
|
76
|
+
blank,
|
|
77
|
+
boxRow(sep, D),
|
|
78
|
+
blank,
|
|
79
|
+
...sRow.map(r => boxRow(r, B)),
|
|
80
|
+
blank,
|
|
81
|
+
`${B}╚${bar}╝${NC}`,
|
|
82
|
+
'',
|
|
83
|
+
` ${R}⚠ Please contact administrator for access${NC}`,
|
|
84
|
+
'',
|
|
85
|
+
];
|
|
86
|
+
return lines.join('\n');
|
|
87
|
+
}
|
|
70
88
|
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
function showAccessDenied() {
|
|
90
|
+
const banner = buildBanner();
|
|
91
|
+
const isPostinstall = process.env.npm_lifecycle_event === 'postinstall';
|
|
92
|
+
|
|
93
|
+
if (isPostinstall) {
|
|
94
|
+
// npm 7+ pipes away stdout/stderr of dependency lifecycle scripts.
|
|
95
|
+
// Write directly to /dev/tty so it reaches the terminal regardless.
|
|
96
|
+
// Skip when invoked by npx — npx installs into ~/.npm/_npx/ before
|
|
97
|
+
// running the CLI, which would show the banner twice.
|
|
98
|
+
const isNpx = __dirname.includes('_npx');
|
|
99
|
+
if (!isNpx) {
|
|
100
|
+
try {
|
|
101
|
+
const fd = fs.openSync('/dev/tty', 'w');
|
|
102
|
+
fs.writeSync(fd, banner + '\n');
|
|
103
|
+
fs.closeSync(fd);
|
|
104
|
+
} catch (_) {
|
|
105
|
+
// No real terminal attached (CI, pipe) — silently skip.
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
process.exit(0);
|
|
109
|
+
}
|
|
90
110
|
|
|
91
|
-
|
|
92
|
-
process.exit(
|
|
111
|
+
console.log(banner);
|
|
112
|
+
process.exit(1);
|
|
93
113
|
}
|
|
94
114
|
|
|
95
115
|
// ── Argument parsing ──────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plc-checkweigher",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "One-command installer for the PLC Check-Weigher system on Raspberry Pi (PREEMPT_RT kernel, Python stack, WiFi, SMB, systemd RT services)",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"postinstall": "node bin/cli.js"
|