ramadan-cal 1.0.3 → 1.0.4
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 +9 -31
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 } from 'fs';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import { homedir } from 'os';
|
|
6
6
|
import { execSync } from 'child_process';
|
|
@@ -77,33 +77,11 @@ function createSkill() {
|
|
|
77
77
|
configureClaudeMd();
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function canPrompt() {
|
|
81
|
-
try {
|
|
82
|
-
const fd = openSync('/dev/tty', 'r+');
|
|
83
|
-
closeSync(fd);
|
|
84
|
-
return true;
|
|
85
|
-
} catch {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
80
|
function ask(question) {
|
|
81
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
91
82
|
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
83
|
rl.question(question, (answer) => {
|
|
104
84
|
rl.close();
|
|
105
|
-
ttyInput.destroy();
|
|
106
|
-
ttyOutput.destroy();
|
|
107
85
|
resolve(answer.trim().toLowerCase());
|
|
108
86
|
});
|
|
109
87
|
});
|
|
@@ -114,6 +92,13 @@ async function main() {
|
|
|
114
92
|
log(' 🌙 Ramadan CLI installed successfully!');
|
|
115
93
|
log('');
|
|
116
94
|
|
|
95
|
+
// Non-interactive environment (CI, piped stdin) — skip prompts
|
|
96
|
+
if (!process.stdin.isTTY) {
|
|
97
|
+
log(' Run `npm rebuild ramadan-cal` in an interactive terminal to set up Claude Code.');
|
|
98
|
+
log('');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
117
102
|
// Step 1: Check if Claude Code is installed
|
|
118
103
|
if (!isClaudeInstalled()) {
|
|
119
104
|
log(' Claude Code not detected on your PATH.');
|
|
@@ -135,13 +120,6 @@ async function main() {
|
|
|
135
120
|
return;
|
|
136
121
|
}
|
|
137
122
|
|
|
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
123
|
// Step 2: Check if skills folder exists
|
|
146
124
|
if (!existsSync(skillsDir)) {
|
|
147
125
|
// Skills folder doesn't exist — ask to create it
|