flowcollab 0.1.6 → 0.1.9
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/_client.mjs +40 -1
- package/package.json +1 -1
package/bin/_client.mjs
CHANGED
|
@@ -4,11 +4,50 @@
|
|
|
4
4
|
- All CLI scripts import from here
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { spawnSync } from 'child_process';
|
|
7
8
|
import 'dotenv/config';
|
|
8
9
|
import { homedir } from 'os';
|
|
9
|
-
import { readFileSync } from 'fs';
|
|
10
|
+
import { readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
10
11
|
import { join } from 'path';
|
|
11
12
|
|
|
13
|
+
// On Windows, Node's bundled CA store doesn't include certs added by corporate/AV
|
|
14
|
+
// TLS inspection software, causing fetch() to throw "fetch failed". Re-spawn with
|
|
15
|
+
// --use-system-ca so Node trusts the Windows certificate store instead.
|
|
16
|
+
// Requires Node 22+; on older Node the child exits with "bad option" which tells
|
|
17
|
+
// the user to upgrade.
|
|
18
|
+
if (process.platform === 'win32' && !process.execArgv.includes('--use-system-ca')) {
|
|
19
|
+
const r = spawnSync(process.execPath, ['--use-system-ca', ...process.argv.slice(1)], {
|
|
20
|
+
stdio: 'inherit',
|
|
21
|
+
env: process.env,
|
|
22
|
+
});
|
|
23
|
+
process.exit(r.status ?? 1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ---- Update notifier ----
|
|
27
|
+
const _updateCache = join(homedir(), '.flow', 'update-check.json');
|
|
28
|
+
let _uc = {};
|
|
29
|
+
try { _uc = JSON.parse(readFileSync(_updateCache, 'utf8')); } catch {}
|
|
30
|
+
|
|
31
|
+
process.on('exit', () => {
|
|
32
|
+
try {
|
|
33
|
+
const { version } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
34
|
+
if (_uc.latest && _uc.latest !== version) {
|
|
35
|
+
process.stderr.write(`\n Update available: ${version} → ${_uc.latest}. Run: npm install -g flowcollab\n`);
|
|
36
|
+
}
|
|
37
|
+
} catch {}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (!_uc.checkedAt || (Date.now() - _uc.checkedAt) > 86_400_000) {
|
|
41
|
+
fetch('https://registry.npmjs.org/flowcollab/latest', { signal: AbortSignal.timeout(4000) })
|
|
42
|
+
.then(r => r.json())
|
|
43
|
+
.then(({ version: latest }) => {
|
|
44
|
+
mkdirSync(join(homedir(), '.flow'), { recursive: true });
|
|
45
|
+
writeFileSync(_updateCache, JSON.stringify({ checkedAt: Date.now(), latest }));
|
|
46
|
+
_uc = { checkedAt: Date.now(), latest };
|
|
47
|
+
})
|
|
48
|
+
.catch(() => {});
|
|
49
|
+
}
|
|
50
|
+
|
|
12
51
|
function loadGlobalConfig() {
|
|
13
52
|
try { return JSON.parse(readFileSync(join(homedir(), '.flow', 'config.json'), 'utf8')); }
|
|
14
53
|
catch { return {}; }
|