unictive-angular 1.1.5 → 1.1.6
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/utils/auth.js +50 -21
- package/bin/utils/createProject.js +18 -1
- package/index.js +2 -2
- package/package.json +1 -1
package/bin/utils/auth.js
CHANGED
|
@@ -8,31 +8,60 @@ const CACHE_FILE = path.join(os.homedir(), ".my-cli-auth");
|
|
|
8
8
|
// Fungsi untuk minta password (input tersembunyi)
|
|
9
9
|
function askPassword(promptText) {
|
|
10
10
|
return new Promise((resolve) => {
|
|
11
|
-
const
|
|
12
|
-
input: process.stdin,
|
|
13
|
-
output: process.stdout
|
|
14
|
-
});
|
|
11
|
+
const stdin = process.stdin;
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
// non-tty (piped input): baca satu baris tanpa masking
|
|
14
|
+
if (!stdin.isTTY) {
|
|
15
|
+
const rl = readline.createInterface({ input: stdin, output: process.stdout });
|
|
16
|
+
rl.question(promptText, (password) => {
|
|
17
|
+
rl.close();
|
|
18
|
+
resolve(password);
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let password = "";
|
|
24
|
+
process.stdout.write(promptText);
|
|
25
|
+
|
|
26
|
+
const cleanup = () => {
|
|
27
|
+
stdin.removeListener("data", onData);
|
|
28
|
+
stdin.setRawMode(false);
|
|
29
|
+
stdin.pause();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const onData = (chunk) => {
|
|
33
|
+
// abaikan tombol panah / escape sequence
|
|
34
|
+
if (chunk.startsWith("\u001b")) return;
|
|
35
|
+
|
|
36
|
+
for (const ch of chunk) {
|
|
37
|
+
if (ch === "\r" || ch === "\n" || ch === "\u0004") {
|
|
38
|
+
cleanup();
|
|
39
|
+
process.stdout.write("\n");
|
|
40
|
+
resolve(password);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (ch === "\u0003") {
|
|
44
|
+
cleanup();
|
|
22
45
|
process.stdout.write("\n");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
process.exit(130);
|
|
47
|
+
}
|
|
48
|
+
if (ch === "\u0008" || ch === "\u007f") {
|
|
49
|
+
if (password.length) {
|
|
50
|
+
password = password.slice(0, -1);
|
|
51
|
+
process.stdout.write("\b \b");
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (ch < " ") continue;
|
|
56
|
+
password += ch;
|
|
57
|
+
process.stdout.write("*");
|
|
29
58
|
}
|
|
30
|
-
}
|
|
59
|
+
};
|
|
31
60
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
61
|
+
stdin.setEncoding("utf8");
|
|
62
|
+
stdin.setRawMode(true);
|
|
63
|
+
stdin.resume();
|
|
64
|
+
stdin.on("data", onData);
|
|
36
65
|
});
|
|
37
66
|
}
|
|
38
67
|
|
|
@@ -107,7 +107,24 @@ async function create_project() {
|
|
|
107
107
|
// let cmd = `ng new ${projectName} ${zoneless ? "--zoneless" : ""} --ssr=false --skip-git --style=css`;
|
|
108
108
|
let cmd = `ng new ${projectName} --zoneless --ssr=false --skip-git --style=css`;
|
|
109
109
|
// let cmd = `ng new ${projectName} --ssr=false --skip-git --style=css`;
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
// di windows, handle stdin milik node masih "membaca" console walau sudah di-pause,
|
|
112
|
+
// sehingga ketikan tidak sampai ke prompt angular. tutup handle-nya (fd 0 tetap diwarisi child)
|
|
113
|
+
// dan beri event loop satu tick agar pembatalan read selesai.
|
|
114
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
115
|
+
process.stdin.pause();
|
|
116
|
+
process.stdin.destroy();
|
|
117
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
118
|
+
|
|
119
|
+
const code = await new Promise((resolve) => {
|
|
120
|
+
const child = spawn(cmd.trim(), { stdio: "inherit", shell: true });
|
|
121
|
+
child.on("error", () => resolve(1));
|
|
122
|
+
child.on("close", resolve);
|
|
123
|
+
});
|
|
124
|
+
if (code !== 0 || !fs.existsSync(projectName)) {
|
|
125
|
+
show_status("Gagal membuat project Angular!", "error");
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
111
128
|
process.chdir(projectName);
|
|
112
129
|
show_status("Project berhasil dibuat!", "success");
|
|
113
130
|
return projectName;
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Script installer Angular Project dengan struktur kustom
|
|
@@ -136,7 +136,7 @@ async function check_dependencies() {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
const ngVersion = execSync("ng version").toString().split("\n").find((l) => l.includes("Angular CLI"));
|
|
139
|
-
await run_with_spinner("ng version", "Memeriksa Angular CLI...", `Angular CLI: ${ngVersion?.split("
|
|
139
|
+
await run_with_spinner("ng version", "Memeriksa Angular CLI...", `Angular CLI: ${ngVersion?.split(":")[1]?.trim() || "Unknown"}`, "Angular CLI terinstall, tapi tidak bisa baca versi");
|
|
140
140
|
console.log("");
|
|
141
141
|
}
|
|
142
142
|
|
package/package.json
CHANGED