plc-checkweigher 1.11.0 → 1.13.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.
Files changed (2) hide show
  1. package/bin/cli.js +6 -20
  2. package/package.json +4 -1
package/bin/cli.js CHANGED
@@ -87,12 +87,9 @@ function showAccessDenied() {
87
87
  console.log('');
88
88
  console.log(` ${R}⚠ Please contact administrator for access${NC}`);
89
89
  console.log('');
90
- console.log(` ${D}Install:${NC} npx plc-checkweigher ${Y}-tov${NC}`);
91
- console.log(` ${D}Uninstall:${NC} npx plc-checkweigher ${Y}-ex${NC}`);
92
- console.log(` ${D}Help:${NC} npx plc-checkweigher ${Y}--help${NC}`);
93
- console.log('');
94
90
 
95
- process.exit(1);
91
+ // Exit 0 when invoked by npm postinstall so the install is not marked failed
92
+ process.exit(process.env.npm_lifecycle_event === 'postinstall' ? 0 : 1);
96
93
  }
97
94
 
98
95
  // ── Argument parsing ──────────────────────────────────────────────────────────
@@ -103,24 +100,13 @@ const UNINSTALL_FLAGS = ['-ex', '--uninstall', 'uninstall', 'remove'];
103
100
  const HELP_FLAGS = ['-h', '--help', 'help'];
104
101
 
105
102
  if (HELP_FLAGS.includes(arg)) {
106
- console.log(`
107
- ${B}npx plc-checkweigher${NC} — PLC Check-Weigher setup utility
108
-
109
- ${Y}npx plc-checkweigher -tov${NC} Install ${D}(set up stack, services, RT kernel)${NC}
110
- ${Y}npx plc-checkweigher -ex${NC} Uninstall ${D}(remove everything)${NC}
111
- ${Y}npx plc-checkweigher --help${NC} Help
112
-
113
- ${D}Aliases:${NC}
114
- ${D}-tov / --install / install${NC}
115
- ${D}-ex / --uninstall / uninstall / remove${NC}
116
- `);
117
- process.exit(0);
103
+ showAccessDenied();
118
104
  }
119
105
 
120
106
  let mode = 'access'; // default: show brand banner + access denied
121
107
  if (INSTALL_FLAGS.includes(arg)) mode = 'install';
122
108
  else if (UNINSTALL_FLAGS.includes(arg)) mode = 'uninstall';
123
- else if (arg !== '') die(`Unknown argument: ${arg}\nRun: npx plc-checkweigher --help`);
109
+ else if (arg !== '') showAccessDenied();
124
110
 
125
111
  // ── Platform guards (skip for help / access-denied) ───────────────────────────
126
112
  if (mode !== 'access') {
@@ -143,7 +129,7 @@ if (mode === 'access') {
143
129
 
144
130
  if (mode === 'install') {
145
131
  if (!fs.existsSync(setupScript))
146
- die('setup.sh not found — try: npx plc-checkweigher@latest -tov');
132
+ die('setup.sh not found — try reinstalling the package: npx plc-checkweigher@latest');
147
133
 
148
134
  console.log(`
149
135
  ${B}╔══════════════════════════════════════════════╗
@@ -171,7 +157,7 @@ ${B}╔════════════════════════
171
157
 
172
158
  if (mode === 'uninstall') {
173
159
  if (!fs.existsSync(uninstallScript))
174
- die('uninstall.sh not found — try: npx plc-checkweigher@latest -ex');
160
+ die('uninstall.sh not found — try reinstalling the package: npx plc-checkweigher@latest');
175
161
 
176
162
  console.log(`
177
163
  ${R}╔══════════════════════════════════════════════╗
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "plc-checkweigher",
3
- "version": "1.11.0",
3
+ "version": "1.13.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
  },