plc-checkweigher 1.12.0 → 1.14.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 +38 -22
- package/package.json +4 -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,27 +66,44 @@ 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
|
-
console.log('');
|
|
88
|
-
console.log(` ${R}⚠ Please contact administrator for access${NC}`);
|
|
89
|
-
console.log('');
|
|
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
|
+
try {
|
|
97
|
+
const fd = fs.openSync('/dev/tty', 'w');
|
|
98
|
+
fs.writeSync(fd, banner + '\n');
|
|
99
|
+
fs.closeSync(fd);
|
|
100
|
+
} catch (_) {
|
|
101
|
+
// No real terminal attached (CI, pipe) — silently skip.
|
|
102
|
+
}
|
|
103
|
+
process.exit(0);
|
|
104
|
+
}
|
|
90
105
|
|
|
106
|
+
console.log(banner);
|
|
91
107
|
process.exit(1);
|
|
92
108
|
}
|
|
93
109
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plc-checkweigher",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.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
|
+
"scripts": {
|
|
6
|
+
"postinstall": "node bin/cli.js"
|
|
7
|
+
},
|
|
5
8
|
"bin": {
|
|
6
9
|
"plc-checkweigher": "bin/cli.js"
|
|
7
10
|
},
|