ramadan-cal 1.0.3 → 1.0.5
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/package.json +1 -1
- package/scripts/postinstall.js +13 -24
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync, appendFileSync,
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, appendFileSync, openSync, createReadStream } from 'fs';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import { homedir } from 'os';
|
|
6
6
|
import { execSync } from 'child_process';
|
|
@@ -77,10 +77,9 @@ function createSkill() {
|
|
|
77
77
|
configureClaudeMd();
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function
|
|
80
|
+
function isTTY() {
|
|
81
81
|
try {
|
|
82
|
-
|
|
83
|
-
closeSync(fd);
|
|
82
|
+
openSync('/dev/tty', 'r');
|
|
84
83
|
return true;
|
|
85
84
|
} catch {
|
|
86
85
|
return false;
|
|
@@ -88,22 +87,12 @@ function canPrompt() {
|
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
function ask(question) {
|
|
90
|
+
const tty = createReadStream('/dev/tty');
|
|
91
|
+
const rl = createInterface({ input: tty, output: process.stderr });
|
|
91
92
|
return new Promise((resolve) => {
|
|
92
|
-
// Use /dev/tty so prompts work even when stdin is piped (npm install)
|
|
93
|
-
let ttyInput, ttyOutput;
|
|
94
|
-
try {
|
|
95
|
-
ttyInput = createReadStream('/dev/tty');
|
|
96
|
-
ttyOutput = createWriteStream('/dev/tty', { flags: 'a' });
|
|
97
|
-
} catch {
|
|
98
|
-
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
99
|
-
rl.question(question, (answer) => { rl.close(); resolve(answer.trim().toLowerCase()); });
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const rl = createInterface({ input: ttyInput, output: ttyOutput });
|
|
103
93
|
rl.question(question, (answer) => {
|
|
104
94
|
rl.close();
|
|
105
|
-
|
|
106
|
-
ttyOutput.destroy();
|
|
95
|
+
tty.destroy();
|
|
107
96
|
resolve(answer.trim().toLowerCase());
|
|
108
97
|
});
|
|
109
98
|
});
|
|
@@ -114,6 +103,13 @@ async function main() {
|
|
|
114
103
|
log(' 🌙 Ramadan CLI installed successfully!');
|
|
115
104
|
log('');
|
|
116
105
|
|
|
106
|
+
// Non-interactive environment (CI, no TTY available) — skip prompts
|
|
107
|
+
if (!isTTY()) {
|
|
108
|
+
log(' Run `npm rebuild ramadan-cal` in an interactive terminal to set up Claude Code.');
|
|
109
|
+
log('');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
117
113
|
// Step 1: Check if Claude Code is installed
|
|
118
114
|
if (!isClaudeInstalled()) {
|
|
119
115
|
log(' Claude Code not detected on your PATH.');
|
|
@@ -135,13 +131,6 @@ async function main() {
|
|
|
135
131
|
return;
|
|
136
132
|
}
|
|
137
133
|
|
|
138
|
-
// If we can't open a terminal for prompts, bail out gracefully
|
|
139
|
-
if (!canPrompt()) {
|
|
140
|
-
log(' Run `npm rebuild ramadan-cal` in your terminal to finish Claude Code setup.');
|
|
141
|
-
log('');
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
134
|
// Step 2: Check if skills folder exists
|
|
146
135
|
if (!existsSync(skillsDir)) {
|
|
147
136
|
// Skills folder doesn't exist — ask to create it
|