catylst 1.0.11 → 1.0.13
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/postinstall.js +28 -19
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -35,20 +35,19 @@ const bold = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
|
35
35
|
const dim = (s) => `\x1b[2m${s}\x1b[0m`;
|
|
36
36
|
const purple = (s) => `\x1b[35m${s}\x1b[0m`;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
/*
|
|
39
|
+
* npm v7+ pipes ALL postinstall stdout/stderr — nothing reaches the terminal.
|
|
40
|
+
* fs.writeSync on /dev/tty bypasses the pipe synchronously; no open handles,
|
|
41
|
+
* no event-loop delay, process exits the moment the last write completes.
|
|
42
|
+
* Falls back to stderr fd (2) on CI / Windows where /dev/tty is unavailable.
|
|
43
|
+
*/
|
|
44
|
+
let ttyFd = 2;
|
|
42
45
|
try {
|
|
43
|
-
// accessSync throws on CI/Windows where /dev/tty doesn't exist or isn't writable.
|
|
44
|
-
// Only open the stream if the device is confirmed accessible.
|
|
45
46
|
fs.accessSync("/dev/tty", fs.constants.W_OK);
|
|
46
|
-
|
|
47
|
-
t.on("error", () => {}); // suppress errors — fallback already set above
|
|
48
|
-
tty = t;
|
|
47
|
+
ttyFd = fs.openSync("/dev/tty", "w");
|
|
49
48
|
} catch (_) {}
|
|
50
|
-
const print = (s) =>
|
|
51
|
-
const printRaw = (s) =>
|
|
49
|
+
const print = (s) => fs.writeSync(ttyFd, s + "\n");
|
|
50
|
+
const printRaw = (s) => fs.writeSync(ttyFd, s);
|
|
52
51
|
|
|
53
52
|
// ── Tips & jokes shown while cloning / downloading ───────────────────────────
|
|
54
53
|
|
|
@@ -125,7 +124,23 @@ function checkJava() {
|
|
|
125
124
|
print(green(` ✓ Java ${major}`));
|
|
126
125
|
}
|
|
127
126
|
|
|
128
|
-
// ── 2.
|
|
127
|
+
// ── 2. Check Android SDK ─────────────────────────────────────────────────────
|
|
128
|
+
|
|
129
|
+
function checkAndroidSdk() {
|
|
130
|
+
const androidHome =
|
|
131
|
+
process.env.ANDROID_HOME ||
|
|
132
|
+
process.env.ANDROID_SDK_ROOT ||
|
|
133
|
+
path.join(os.homedir(), "Library", "Android", "sdk");
|
|
134
|
+
|
|
135
|
+
if (fs.existsSync(androidHome)) {
|
|
136
|
+
print(green(` ✓ Android SDK`));
|
|
137
|
+
} else {
|
|
138
|
+
print(yellow(" ⚠ Android SDK not found. Set ANDROID_HOME or add sdk.dir to local.properties."));
|
|
139
|
+
print(dim(" Download Android Studio: https://developer.android.com/studio"));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ── 3. Clone / update template ───────────────────────────────────────────────
|
|
129
144
|
|
|
130
145
|
function setupTemplate() {
|
|
131
146
|
fs.mkdirSync(CATYLST_DIR, { recursive: true });
|
|
@@ -261,6 +276,7 @@ function downloadJar() {
|
|
|
261
276
|
|
|
262
277
|
(async () => {
|
|
263
278
|
checkJava();
|
|
279
|
+
checkAndroidSdk();
|
|
264
280
|
setupTemplate();
|
|
265
281
|
await downloadJar();
|
|
266
282
|
|
|
@@ -273,11 +289,4 @@ function downloadJar() {
|
|
|
273
289
|
print(" " + dim("Or non-interactive:"));
|
|
274
290
|
print(" " + dim("catylst --package com.example.app --name MyApp"));
|
|
275
291
|
print("");
|
|
276
|
-
|
|
277
|
-
// The /dev/tty WriteStream holds the event loop open after all output is
|
|
278
|
-
// written, making the process appear to hang. Close it so the process exits
|
|
279
|
-
// on its own without npm having to send SIGINT.
|
|
280
|
-
if (tty !== process.stderr) {
|
|
281
|
-
tty.end(() => process.exit(0));
|
|
282
|
-
}
|
|
283
292
|
})();
|