notchi 0.0.0-stage → 0.9.40
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/notchi.js +75 -0
- package/package.json +28 -4
- package/README.md +0 -3
package/bin/notchi.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// npx notchi: downloads the latest Notchi release from GitHub, installs it
|
|
3
|
+
// into /Applications, clears the quarantine flag and launches it.
|
|
4
|
+
'use strict';
|
|
5
|
+
const { execFileSync } = require('child_process');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const REPO = 'cyrus-cai/notchi';
|
|
11
|
+
const APP = 'Notchi.app';
|
|
12
|
+
const DEST = path.join('/Applications', APP);
|
|
13
|
+
const LEGACY = ['Notch.app', 'NotchGlass.app'];
|
|
14
|
+
|
|
15
|
+
const tty = process.stdout.isTTY;
|
|
16
|
+
const c = (code, s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
17
|
+
const info = (s) => console.log(`${c(1, '==>')} ${s}`);
|
|
18
|
+
const ok = (s) => console.log(`${c(32, '✓')} ${s}`);
|
|
19
|
+
const die = (s) => { console.error(`${c(31, '✗')} ${s}`); process.exit(1); };
|
|
20
|
+
|
|
21
|
+
async function main() {
|
|
22
|
+
if (process.platform !== 'darwin') die('Notchi is a macOS app. This installer only runs on macOS.');
|
|
23
|
+
|
|
24
|
+
info(`Looking up the latest release of ${REPO}…`);
|
|
25
|
+
// curl, not fetch: curl follows the http(s)_proxy environment variables.
|
|
26
|
+
let rel;
|
|
27
|
+
try { rel = JSON.parse(execFileSync('curl', ['-fsSL', '-H', 'User-Agent: notchi-npx', `https://api.github.com/repos/${REPO}/releases/latest`], { encoding: 'utf8' })); }
|
|
28
|
+
catch { die('Could not reach the GitHub API.'); }
|
|
29
|
+
const asset = (rel.assets || []).find((a) => a.name.endsWith('.zip'));
|
|
30
|
+
if (!asset) die('No .zip asset found on the latest release.');
|
|
31
|
+
ok(`Found ${rel.tag_name}: ${asset.name}`);
|
|
32
|
+
|
|
33
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'notchi-'));
|
|
34
|
+
try {
|
|
35
|
+
info('Downloading…');
|
|
36
|
+
const zip = path.join(tmp, 'notchi.zip');
|
|
37
|
+
try { execFileSync('curl', ['-fL', '--progress-bar', '-o', zip, asset.browser_download_url], { stdio: ['ignore', 'ignore', 'inherit'] }); }
|
|
38
|
+
catch { die('Download failed.'); }
|
|
39
|
+
|
|
40
|
+
info('Unpacking…');
|
|
41
|
+
const out = path.join(tmp, 'x');
|
|
42
|
+
execFileSync('ditto', ['-x', '-k', zip, out]);
|
|
43
|
+
const names = [APP, ...LEGACY];
|
|
44
|
+
let src = null;
|
|
45
|
+
for (const top of [out, ...fs.readdirSync(out).map((n) => path.join(out, n))]) {
|
|
46
|
+
for (const n of names) if (fs.existsSync(path.join(top, n))) { src = path.join(top, n); break; }
|
|
47
|
+
if (src) break;
|
|
48
|
+
}
|
|
49
|
+
if (!src) die(`Could not find ${APP} inside the archive.`);
|
|
50
|
+
|
|
51
|
+
if (fs.existsSync(DEST)) {
|
|
52
|
+
info(`Replacing existing ${APP}…`);
|
|
53
|
+
try { fs.rmSync(DEST, { recursive: true, force: true }); }
|
|
54
|
+
catch { die(`Could not remove old ${DEST} (try: sudo rm -rf "${DEST}").`); }
|
|
55
|
+
}
|
|
56
|
+
for (const n of LEGACY) {
|
|
57
|
+
const p = path.join('/Applications', n);
|
|
58
|
+
if (fs.existsSync(p)) { info(`Removing legacy ${n}…`); fs.rmSync(p, { recursive: true, force: true }); }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
info('Installing to /Applications…');
|
|
62
|
+
try { execFileSync('ditto', [src, DEST]); }
|
|
63
|
+
catch { die('Could not copy into /Applications (you may need write permission).'); }
|
|
64
|
+
try { execFileSync('xattr', ['-dr', 'com.apple.quarantine', DEST]); } catch {}
|
|
65
|
+
|
|
66
|
+
ok(`Notchi installed to ${DEST}`);
|
|
67
|
+
info('Launching…');
|
|
68
|
+
try { execFileSync('open', [DEST]); } catch {}
|
|
69
|
+
console.log(`\n${c(1, 'Done.')} Hover your notch to wake it.`);
|
|
70
|
+
} finally {
|
|
71
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
main().catch((e) => die(e.message || String(e)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notchi",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.9.40",
|
|
4
|
+
"description": "Install Notchi, the macOS notch AI app, with one command: npx notchi",
|
|
5
|
+
"bin": {
|
|
6
|
+
"notchi": "bin/notchi.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin"
|
|
10
|
+
],
|
|
11
|
+
"os": [
|
|
12
|
+
"darwin"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://notch.website",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/cyrus-cai/notchi.git"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"notchi",
|
|
25
|
+
"macos",
|
|
26
|
+
"notch",
|
|
27
|
+
"ai",
|
|
28
|
+
"installer"
|
|
29
|
+
]
|
|
30
|
+
}
|
package/README.md
DELETED