tokalytics 2.0.6 → 2.0.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/README.md +2 -0
- package/package.json +1 -1
- package/scripts/postinstall.js +28 -1
package/README.md
CHANGED
|
@@ -47,6 +47,8 @@ Na primeira execução o app sobe o **servidor HTTP na porta `3456`** e o ícone
|
|
|
47
47
|
npm install -g tokalytics
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
Em instalação **global**, o `postinstall` tenta **abrir o Tokalytics em segundo plano** (ícone na barra). Para instalar sem iniciar: `TOKALYTICS_NO_AUTOSTART=1 npm install -g tokalytics`.
|
|
51
|
+
|
|
50
52
|
Instalação a partir do repositório (sempre o `postinstall` da branch atual):
|
|
51
53
|
|
|
52
54
|
```bash
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
const https = require('https');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
|
+
const { spawn } = require('child_process');
|
|
7
8
|
|
|
8
9
|
const pkgPath = path.join(__dirname, '..', 'package.json');
|
|
9
10
|
const pkgVersion = (() => {
|
|
@@ -127,6 +128,26 @@ function assertReleasePayload(release) {
|
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
/** Só em `npm install -g` (npm_config_global). Ignora CI e TOKALYTICS_NO_AUTOSTART=1. */
|
|
132
|
+
function tryLaunchAfterGlobalInstall() {
|
|
133
|
+
if (process.env.CI === 'true') return false;
|
|
134
|
+
if (process.env.TOKALYTICS_NO_AUTOSTART === '1') return false;
|
|
135
|
+
const g = process.env.npm_config_global;
|
|
136
|
+
if (g !== 'true' && g !== '1') return false;
|
|
137
|
+
if (!fs.existsSync(BIN_PATH)) return false;
|
|
138
|
+
try {
|
|
139
|
+
const child = spawn(BIN_PATH, [], {
|
|
140
|
+
detached: true,
|
|
141
|
+
stdio: 'ignore',
|
|
142
|
+
windowsHide: true,
|
|
143
|
+
});
|
|
144
|
+
child.unref();
|
|
145
|
+
return true;
|
|
146
|
+
} catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
130
151
|
async function install() {
|
|
131
152
|
console.log(`Tokalytics installer v${pkgVersion}: buscando última versão...`);
|
|
132
153
|
|
|
@@ -148,7 +169,13 @@ async function install() {
|
|
|
148
169
|
fs.chmodSync(BIN_PATH, 0o755);
|
|
149
170
|
|
|
150
171
|
console.log(`Tokalytics ${version} instalado com sucesso!`);
|
|
151
|
-
|
|
172
|
+
if (tryLaunchAfterGlobalInstall()) {
|
|
173
|
+
console.log(
|
|
174
|
+
'Tokalytics iniciado em segundo plano (ícone na barra de menus / bandeja).'
|
|
175
|
+
);
|
|
176
|
+
} else {
|
|
177
|
+
console.log('Execute: tokalytics');
|
|
178
|
+
}
|
|
152
179
|
}
|
|
153
180
|
|
|
154
181
|
install().catch((err) => {
|