happy-coder 0.3.1-beta.1 → 0.4.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/dist/index.cjs +76 -27
- package/dist/index.mjs +76 -27
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +1 -0
- package/dist/lib.d.mts +1 -0
- package/dist/lib.mjs +1 -1
- package/dist/{types-CzYKFAYa.mjs → types-VkaGP8up.mjs} +1 -1
- package/dist/{types-D7u2DxfV.cjs → types-eN-YHsuj.cjs} +1 -0
- package/package.json +8 -6
- package/dist/index-B2GqfEZV.cjs +0 -1564
- package/dist/index-QItBXhux.mjs +0 -1540
- package/dist/install-B0DnBGS_.mjs +0 -29
- package/dist/install-B2r_gX72.cjs +0 -109
- package/dist/install-C809w0Cj.cjs +0 -31
- package/dist/install-DEPy62QN.mjs +0 -97
- package/dist/install-GZIzyuIE.cjs +0 -99
- package/dist/install-HKe7dyS4.mjs +0 -107
- package/dist/run-BmEaINbl.cjs +0 -250
- package/dist/run-DMbKhYfb.mjs +0 -247
- package/dist/run-FBXkmmN7.mjs +0 -32
- package/dist/run-q2To6b-c.cjs +0 -34
- package/dist/types-BG9AgCI4.mjs +0 -875
- package/dist/types-BRICSarm.mjs +0 -870
- package/dist/types-BTQRfIr3.cjs +0 -892
- package/dist/types-BX4xv8Ty.mjs +0 -881
- package/dist/types-BeUppqJU.cjs +0 -886
- package/dist/types-C6Wx_bRW.cjs +0 -886
- package/dist/types-CEvzGLMI.cjs +0 -882
- package/dist/types-CKUdOV6c.mjs +0 -875
- package/dist/types-CNuBtNA5.cjs +0 -884
- package/dist/types-Cg4664gs.cjs +0 -879
- package/dist/types-CkPUFpfr.cjs +0 -885
- package/dist/types-D39L8JSd.mjs +0 -850
- package/dist/types-DD9P_5rj.mjs +0 -868
- package/dist/types-DNu8okOb.mjs +0 -874
- package/dist/types-DXK5YldG.cjs +0 -892
- package/dist/types-DYBiuNUQ.cjs +0 -883
- package/dist/types-Df5dlWLV.mjs +0 -871
- package/dist/types-fXgEaaqP.mjs +0 -861
- package/dist/types-hotUTaWz.cjs +0 -863
- package/dist/types-ikrrEcJm.mjs +0 -873
- package/dist/types-mykDX2xe.cjs +0 -872
- package/dist/types-tLWMaptR.mjs +0 -879
- package/dist/uninstall-BGgl5V8F.mjs +0 -29
- package/dist/uninstall-BWHglipH.mjs +0 -40
- package/dist/uninstall-C42CoSCI.cjs +0 -53
- package/dist/uninstall-CLkTtlMv.mjs +0 -51
- package/dist/uninstall-CdHMb6wi.cjs +0 -31
- package/dist/uninstall-FXyyAuGU.cjs +0 -42
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { l as logger } from './types-BRICSarm.mjs';
|
|
2
|
-
import { install as install$1 } from './install-DEPy62QN.mjs';
|
|
3
|
-
import 'axios';
|
|
4
|
-
import 'chalk';
|
|
5
|
-
import 'fs';
|
|
6
|
-
import 'node:os';
|
|
7
|
-
import 'node:path';
|
|
8
|
-
import 'node:fs/promises';
|
|
9
|
-
import 'node:fs';
|
|
10
|
-
import 'node:events';
|
|
11
|
-
import 'socket.io-client';
|
|
12
|
-
import 'zod';
|
|
13
|
-
import 'node:crypto';
|
|
14
|
-
import 'tweetnacl';
|
|
15
|
-
import 'expo-server-sdk';
|
|
16
|
-
import 'child_process';
|
|
17
|
-
|
|
18
|
-
async function install() {
|
|
19
|
-
if (process.platform !== "darwin") {
|
|
20
|
-
throw new Error("Daemon installation is currently only supported on macOS");
|
|
21
|
-
}
|
|
22
|
-
if (process.getuid && process.getuid() !== 0) {
|
|
23
|
-
throw new Error("Daemon installation requires sudo privileges. Please run with sudo.");
|
|
24
|
-
}
|
|
25
|
-
logger.info("Installing Happy CLI daemon for macOS...");
|
|
26
|
-
await install$1();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { install };
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var types = require('./types-mykDX2xe.cjs');
|
|
4
|
-
var fs = require('fs');
|
|
5
|
-
var child_process = require('child_process');
|
|
6
|
-
require('axios');
|
|
7
|
-
require('chalk');
|
|
8
|
-
require('node:os');
|
|
9
|
-
require('node:path');
|
|
10
|
-
require('node:fs/promises');
|
|
11
|
-
require('node:fs');
|
|
12
|
-
require('node:events');
|
|
13
|
-
require('socket.io-client');
|
|
14
|
-
require('zod');
|
|
15
|
-
require('node:crypto');
|
|
16
|
-
require('tweetnacl');
|
|
17
|
-
require('expo-server-sdk');
|
|
18
|
-
|
|
19
|
-
function trimIdent(text) {
|
|
20
|
-
const lines = text.split("\n");
|
|
21
|
-
while (lines.length > 0 && lines[0].trim() === "") {
|
|
22
|
-
lines.shift();
|
|
23
|
-
}
|
|
24
|
-
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
25
|
-
lines.pop();
|
|
26
|
-
}
|
|
27
|
-
const minSpaces = lines.reduce((min, line) => {
|
|
28
|
-
if (line.trim() === "") {
|
|
29
|
-
return min;
|
|
30
|
-
}
|
|
31
|
-
const leadingSpaces = line.match(/^\s*/)[0].length;
|
|
32
|
-
return Math.min(min, leadingSpaces);
|
|
33
|
-
}, Infinity);
|
|
34
|
-
const trimmedLines = lines.map((line) => line.slice(minSpaces));
|
|
35
|
-
return trimmedLines.join("\n");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const PLIST_LABEL = "com.happy-cli.daemon";
|
|
39
|
-
const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
|
|
40
|
-
async function install$1() {
|
|
41
|
-
try {
|
|
42
|
-
if (fs.existsSync(PLIST_FILE)) {
|
|
43
|
-
types.logger.info("Daemon plist already exists. Uninstalling first...");
|
|
44
|
-
child_process.execSync(`launchctl unload ${PLIST_FILE}`, { stdio: "inherit" });
|
|
45
|
-
}
|
|
46
|
-
const happyPath = process.argv[0];
|
|
47
|
-
const scriptPath = process.argv[1];
|
|
48
|
-
const plistContent = trimIdent(`
|
|
49
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
50
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
51
|
-
<plist version="1.0">
|
|
52
|
-
<dict>
|
|
53
|
-
<key>Label</key>
|
|
54
|
-
<string>${PLIST_LABEL}</string>
|
|
55
|
-
|
|
56
|
-
<key>ProgramArguments</key>
|
|
57
|
-
<array>
|
|
58
|
-
<string>${happyPath}</string>
|
|
59
|
-
<string>${scriptPath}</string>
|
|
60
|
-
<string>daemon</string>
|
|
61
|
-
</array>
|
|
62
|
-
|
|
63
|
-
<key>EnvironmentVariables</key>
|
|
64
|
-
<dict>
|
|
65
|
-
<key>HAPPY_DAEMON_MODE</key>
|
|
66
|
-
<string>true</string>
|
|
67
|
-
</dict>
|
|
68
|
-
|
|
69
|
-
<key>RunAtLoad</key>
|
|
70
|
-
<true/>
|
|
71
|
-
|
|
72
|
-
<key>KeepAlive</key>
|
|
73
|
-
<true/>
|
|
74
|
-
|
|
75
|
-
<key>StandardErrorPath</key>
|
|
76
|
-
<string>/var/log/happy-cli-daemon.err</string>
|
|
77
|
-
|
|
78
|
-
<key>StandardOutPath</key>
|
|
79
|
-
<string>/var/log/happy-cli-daemon.log</string>
|
|
80
|
-
|
|
81
|
-
<key>WorkingDirectory</key>
|
|
82
|
-
<string>/tmp</string>
|
|
83
|
-
</dict>
|
|
84
|
-
</plist>
|
|
85
|
-
`);
|
|
86
|
-
fs.writeFileSync(PLIST_FILE, plistContent);
|
|
87
|
-
fs.chmodSync(PLIST_FILE, 420);
|
|
88
|
-
types.logger.info(`Created daemon plist at ${PLIST_FILE}`);
|
|
89
|
-
child_process.execSync(`launchctl load ${PLIST_FILE}`, { stdio: "inherit" });
|
|
90
|
-
types.logger.info("Daemon installed and started successfully");
|
|
91
|
-
types.logger.info("Check logs at /var/log/happy-cli-daemon.log");
|
|
92
|
-
} catch (error) {
|
|
93
|
-
types.logger.debug("Failed to install daemon:", error);
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async function install() {
|
|
99
|
-
if (process.platform !== "darwin") {
|
|
100
|
-
throw new Error("Daemon installation is currently only supported on macOS");
|
|
101
|
-
}
|
|
102
|
-
if (process.getuid && process.getuid() !== 0) {
|
|
103
|
-
throw new Error("Daemon installation requires sudo privileges. Please run with sudo.");
|
|
104
|
-
}
|
|
105
|
-
types.logger.info("Installing Happy CLI daemon for macOS...");
|
|
106
|
-
await install$1();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
exports.install = install;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var types = require('./types-DYBiuNUQ.cjs');
|
|
4
|
-
var install$1 = require('./install-GZIzyuIE.cjs');
|
|
5
|
-
require('axios');
|
|
6
|
-
require('chalk');
|
|
7
|
-
require('fs');
|
|
8
|
-
require('node:os');
|
|
9
|
-
require('node:path');
|
|
10
|
-
require('node:fs/promises');
|
|
11
|
-
require('node:fs');
|
|
12
|
-
require('node:events');
|
|
13
|
-
require('socket.io-client');
|
|
14
|
-
require('zod');
|
|
15
|
-
require('node:crypto');
|
|
16
|
-
require('tweetnacl');
|
|
17
|
-
require('expo-server-sdk');
|
|
18
|
-
require('child_process');
|
|
19
|
-
|
|
20
|
-
async function install() {
|
|
21
|
-
if (process.platform !== "darwin") {
|
|
22
|
-
throw new Error("Daemon installation is currently only supported on macOS");
|
|
23
|
-
}
|
|
24
|
-
if (process.getuid && process.getuid() !== 0) {
|
|
25
|
-
throw new Error("Daemon installation requires sudo privileges. Please run with sudo.");
|
|
26
|
-
}
|
|
27
|
-
types.logger.info("Installing Happy CLI daemon for macOS...");
|
|
28
|
-
await install$1.install();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.install = install;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { existsSync, writeFileSync, chmodSync } from 'fs';
|
|
2
|
-
import { execSync } from 'child_process';
|
|
3
|
-
import { l as logger } from './types-BRICSarm.mjs';
|
|
4
|
-
import 'axios';
|
|
5
|
-
import 'chalk';
|
|
6
|
-
import 'node:os';
|
|
7
|
-
import 'node:path';
|
|
8
|
-
import 'node:fs/promises';
|
|
9
|
-
import 'node:fs';
|
|
10
|
-
import 'node:events';
|
|
11
|
-
import 'socket.io-client';
|
|
12
|
-
import 'zod';
|
|
13
|
-
import 'node:crypto';
|
|
14
|
-
import 'tweetnacl';
|
|
15
|
-
import 'expo-server-sdk';
|
|
16
|
-
|
|
17
|
-
function trimIdent(text) {
|
|
18
|
-
const lines = text.split("\n");
|
|
19
|
-
while (lines.length > 0 && lines[0].trim() === "") {
|
|
20
|
-
lines.shift();
|
|
21
|
-
}
|
|
22
|
-
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
23
|
-
lines.pop();
|
|
24
|
-
}
|
|
25
|
-
const minSpaces = lines.reduce((min, line) => {
|
|
26
|
-
if (line.trim() === "") {
|
|
27
|
-
return min;
|
|
28
|
-
}
|
|
29
|
-
const leadingSpaces = line.match(/^\s*/)[0].length;
|
|
30
|
-
return Math.min(min, leadingSpaces);
|
|
31
|
-
}, Infinity);
|
|
32
|
-
const trimmedLines = lines.map((line) => line.slice(minSpaces));
|
|
33
|
-
return trimmedLines.join("\n");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const PLIST_LABEL = "com.happy-cli.daemon";
|
|
37
|
-
const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
|
|
38
|
-
const USER_HOME = process.env.HOME || process.env.USERPROFILE;
|
|
39
|
-
async function install() {
|
|
40
|
-
try {
|
|
41
|
-
if (existsSync(PLIST_FILE)) {
|
|
42
|
-
logger.info("Daemon plist already exists. Uninstalling first...");
|
|
43
|
-
execSync(`launchctl unload ${PLIST_FILE}`, { stdio: "inherit" });
|
|
44
|
-
}
|
|
45
|
-
const happyPath = process.argv[0];
|
|
46
|
-
const scriptPath = process.argv[1];
|
|
47
|
-
const plistContent = trimIdent(`
|
|
48
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
49
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
50
|
-
<plist version="1.0">
|
|
51
|
-
<dict>
|
|
52
|
-
<key>Label</key>
|
|
53
|
-
<string>${PLIST_LABEL}</string>
|
|
54
|
-
|
|
55
|
-
<key>ProgramArguments</key>
|
|
56
|
-
<array>
|
|
57
|
-
<string>${happyPath}</string>
|
|
58
|
-
<string>${scriptPath}</string>
|
|
59
|
-
<string>daemon</string>
|
|
60
|
-
</array>
|
|
61
|
-
|
|
62
|
-
<key>EnvironmentVariables</key>
|
|
63
|
-
<dict>
|
|
64
|
-
<key>HAPPY_DAEMON_MODE</key>
|
|
65
|
-
<string>true</string>
|
|
66
|
-
</dict>
|
|
67
|
-
|
|
68
|
-
<key>RunAtLoad</key>
|
|
69
|
-
<true/>
|
|
70
|
-
|
|
71
|
-
<key>KeepAlive</key>
|
|
72
|
-
<true/>
|
|
73
|
-
|
|
74
|
-
<key>StandardErrorPath</key>
|
|
75
|
-
<string>${USER_HOME}/.happy/happy-cli-daemon.err</string>
|
|
76
|
-
|
|
77
|
-
<key>StandardOutPath</key>
|
|
78
|
-
<string>${USER_HOME}/.happy/happy-cli-daemon.log</string>
|
|
79
|
-
|
|
80
|
-
<key>WorkingDirectory</key>
|
|
81
|
-
<string>/tmp</string>
|
|
82
|
-
</dict>
|
|
83
|
-
</plist>
|
|
84
|
-
`);
|
|
85
|
-
writeFileSync(PLIST_FILE, plistContent);
|
|
86
|
-
chmodSync(PLIST_FILE, 420);
|
|
87
|
-
logger.info(`Created daemon plist at ${PLIST_FILE}`);
|
|
88
|
-
execSync(`launchctl load ${PLIST_FILE}`, { stdio: "inherit" });
|
|
89
|
-
logger.info("Daemon installed and started successfully");
|
|
90
|
-
logger.info("Check logs at /var/log/happy-cli-daemon.log");
|
|
91
|
-
} catch (error) {
|
|
92
|
-
logger.debug("Failed to install daemon:", error);
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { install };
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var child_process = require('child_process');
|
|
5
|
-
var types = require('./types-DYBiuNUQ.cjs');
|
|
6
|
-
require('axios');
|
|
7
|
-
require('chalk');
|
|
8
|
-
require('node:os');
|
|
9
|
-
require('node:path');
|
|
10
|
-
require('node:fs/promises');
|
|
11
|
-
require('node:fs');
|
|
12
|
-
require('node:events');
|
|
13
|
-
require('socket.io-client');
|
|
14
|
-
require('zod');
|
|
15
|
-
require('node:crypto');
|
|
16
|
-
require('tweetnacl');
|
|
17
|
-
require('expo-server-sdk');
|
|
18
|
-
|
|
19
|
-
function trimIdent(text) {
|
|
20
|
-
const lines = text.split("\n");
|
|
21
|
-
while (lines.length > 0 && lines[0].trim() === "") {
|
|
22
|
-
lines.shift();
|
|
23
|
-
}
|
|
24
|
-
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
25
|
-
lines.pop();
|
|
26
|
-
}
|
|
27
|
-
const minSpaces = lines.reduce((min, line) => {
|
|
28
|
-
if (line.trim() === "") {
|
|
29
|
-
return min;
|
|
30
|
-
}
|
|
31
|
-
const leadingSpaces = line.match(/^\s*/)[0].length;
|
|
32
|
-
return Math.min(min, leadingSpaces);
|
|
33
|
-
}, Infinity);
|
|
34
|
-
const trimmedLines = lines.map((line) => line.slice(minSpaces));
|
|
35
|
-
return trimmedLines.join("\n");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const PLIST_LABEL = "com.happy-cli.daemon";
|
|
39
|
-
const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
|
|
40
|
-
const USER_HOME = process.env.HOME || process.env.USERPROFILE;
|
|
41
|
-
async function install() {
|
|
42
|
-
try {
|
|
43
|
-
if (fs.existsSync(PLIST_FILE)) {
|
|
44
|
-
types.logger.info("Daemon plist already exists. Uninstalling first...");
|
|
45
|
-
child_process.execSync(`launchctl unload ${PLIST_FILE}`, { stdio: "inherit" });
|
|
46
|
-
}
|
|
47
|
-
const happyPath = process.argv[0];
|
|
48
|
-
const scriptPath = process.argv[1];
|
|
49
|
-
const plistContent = trimIdent(`
|
|
50
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
51
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
52
|
-
<plist version="1.0">
|
|
53
|
-
<dict>
|
|
54
|
-
<key>Label</key>
|
|
55
|
-
<string>${PLIST_LABEL}</string>
|
|
56
|
-
|
|
57
|
-
<key>ProgramArguments</key>
|
|
58
|
-
<array>
|
|
59
|
-
<string>${happyPath}</string>
|
|
60
|
-
<string>${scriptPath}</string>
|
|
61
|
-
<string>daemon</string>
|
|
62
|
-
</array>
|
|
63
|
-
|
|
64
|
-
<key>EnvironmentVariables</key>
|
|
65
|
-
<dict>
|
|
66
|
-
<key>HAPPY_DAEMON_MODE</key>
|
|
67
|
-
<string>true</string>
|
|
68
|
-
</dict>
|
|
69
|
-
|
|
70
|
-
<key>RunAtLoad</key>
|
|
71
|
-
<true/>
|
|
72
|
-
|
|
73
|
-
<key>KeepAlive</key>
|
|
74
|
-
<true/>
|
|
75
|
-
|
|
76
|
-
<key>StandardErrorPath</key>
|
|
77
|
-
<string>${USER_HOME}/.happy/happy-cli-daemon.err</string>
|
|
78
|
-
|
|
79
|
-
<key>StandardOutPath</key>
|
|
80
|
-
<string>${USER_HOME}/.happy/happy-cli-daemon.log</string>
|
|
81
|
-
|
|
82
|
-
<key>WorkingDirectory</key>
|
|
83
|
-
<string>/tmp</string>
|
|
84
|
-
</dict>
|
|
85
|
-
</plist>
|
|
86
|
-
`);
|
|
87
|
-
fs.writeFileSync(PLIST_FILE, plistContent);
|
|
88
|
-
fs.chmodSync(PLIST_FILE, 420);
|
|
89
|
-
types.logger.info(`Created daemon plist at ${PLIST_FILE}`);
|
|
90
|
-
child_process.execSync(`launchctl load ${PLIST_FILE}`, { stdio: "inherit" });
|
|
91
|
-
types.logger.info("Daemon installed and started successfully");
|
|
92
|
-
types.logger.info("Check logs at /var/log/happy-cli-daemon.log");
|
|
93
|
-
} catch (error) {
|
|
94
|
-
types.logger.debug("Failed to install daemon:", error);
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
exports.install = install;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { l as logger } from './types-fXgEaaqP.mjs';
|
|
2
|
-
import { existsSync, writeFileSync, chmodSync } from 'fs';
|
|
3
|
-
import { execSync } from 'child_process';
|
|
4
|
-
import 'axios';
|
|
5
|
-
import 'chalk';
|
|
6
|
-
import 'node:os';
|
|
7
|
-
import 'node:path';
|
|
8
|
-
import 'node:fs/promises';
|
|
9
|
-
import 'node:fs';
|
|
10
|
-
import 'node:events';
|
|
11
|
-
import 'socket.io-client';
|
|
12
|
-
import 'zod';
|
|
13
|
-
import 'node:crypto';
|
|
14
|
-
import 'tweetnacl';
|
|
15
|
-
import 'expo-server-sdk';
|
|
16
|
-
|
|
17
|
-
function trimIdent(text) {
|
|
18
|
-
const lines = text.split("\n");
|
|
19
|
-
while (lines.length > 0 && lines[0].trim() === "") {
|
|
20
|
-
lines.shift();
|
|
21
|
-
}
|
|
22
|
-
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
23
|
-
lines.pop();
|
|
24
|
-
}
|
|
25
|
-
const minSpaces = lines.reduce((min, line) => {
|
|
26
|
-
if (line.trim() === "") {
|
|
27
|
-
return min;
|
|
28
|
-
}
|
|
29
|
-
const leadingSpaces = line.match(/^\s*/)[0].length;
|
|
30
|
-
return Math.min(min, leadingSpaces);
|
|
31
|
-
}, Infinity);
|
|
32
|
-
const trimmedLines = lines.map((line) => line.slice(minSpaces));
|
|
33
|
-
return trimmedLines.join("\n");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const PLIST_LABEL = "com.happy-cli.daemon";
|
|
37
|
-
const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
|
|
38
|
-
async function install$1() {
|
|
39
|
-
try {
|
|
40
|
-
if (existsSync(PLIST_FILE)) {
|
|
41
|
-
logger.info("Daemon plist already exists. Uninstalling first...");
|
|
42
|
-
execSync(`launchctl unload ${PLIST_FILE}`, { stdio: "inherit" });
|
|
43
|
-
}
|
|
44
|
-
const happyPath = process.argv[0];
|
|
45
|
-
const scriptPath = process.argv[1];
|
|
46
|
-
const plistContent = trimIdent(`
|
|
47
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
48
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
49
|
-
<plist version="1.0">
|
|
50
|
-
<dict>
|
|
51
|
-
<key>Label</key>
|
|
52
|
-
<string>${PLIST_LABEL}</string>
|
|
53
|
-
|
|
54
|
-
<key>ProgramArguments</key>
|
|
55
|
-
<array>
|
|
56
|
-
<string>${happyPath}</string>
|
|
57
|
-
<string>${scriptPath}</string>
|
|
58
|
-
<string>daemon</string>
|
|
59
|
-
</array>
|
|
60
|
-
|
|
61
|
-
<key>EnvironmentVariables</key>
|
|
62
|
-
<dict>
|
|
63
|
-
<key>HAPPY_DAEMON_MODE</key>
|
|
64
|
-
<string>true</string>
|
|
65
|
-
</dict>
|
|
66
|
-
|
|
67
|
-
<key>RunAtLoad</key>
|
|
68
|
-
<true/>
|
|
69
|
-
|
|
70
|
-
<key>KeepAlive</key>
|
|
71
|
-
<true/>
|
|
72
|
-
|
|
73
|
-
<key>StandardErrorPath</key>
|
|
74
|
-
<string>/var/log/happy-cli-daemon.err</string>
|
|
75
|
-
|
|
76
|
-
<key>StandardOutPath</key>
|
|
77
|
-
<string>/var/log/happy-cli-daemon.log</string>
|
|
78
|
-
|
|
79
|
-
<key>WorkingDirectory</key>
|
|
80
|
-
<string>/tmp</string>
|
|
81
|
-
</dict>
|
|
82
|
-
</plist>
|
|
83
|
-
`);
|
|
84
|
-
writeFileSync(PLIST_FILE, plistContent);
|
|
85
|
-
chmodSync(PLIST_FILE, 420);
|
|
86
|
-
logger.info(`Created daemon plist at ${PLIST_FILE}`);
|
|
87
|
-
execSync(`launchctl load ${PLIST_FILE}`, { stdio: "inherit" });
|
|
88
|
-
logger.info("Daemon installed and started successfully");
|
|
89
|
-
logger.info("Check logs at /var/log/happy-cli-daemon.log");
|
|
90
|
-
} catch (error) {
|
|
91
|
-
logger.debug("Failed to install daemon:", error);
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function install() {
|
|
97
|
-
if (process.platform !== "darwin") {
|
|
98
|
-
throw new Error("Daemon installation is currently only supported on macOS");
|
|
99
|
-
}
|
|
100
|
-
if (process.getuid && process.getuid() !== 0) {
|
|
101
|
-
throw new Error("Daemon installation requires sudo privileges. Please run with sudo.");
|
|
102
|
-
}
|
|
103
|
-
logger.info("Installing Happy CLI daemon for macOS...");
|
|
104
|
-
await install$1();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export { install };
|