@dongdev/fca-unofficial 2.0.8 → 2.0.10

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/LICENSE-MIT DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Avery, Benjamin, David, Maude
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,58 +0,0 @@
1
- const logger = require("./logger");
2
- const fs = require("fs");
3
- const { exec } = require("child_process");
4
- const pkgName = "@dongdev/fca-unofficial";
5
-
6
- function execPromise(cmd) {
7
- return new Promise((resolve, reject) => {
8
- exec(cmd, (error, stdout, stderr) => {
9
- if (error) return reject({ error, stderr });
10
- resolve({ stdout, stderr });
11
- });
12
- });
13
- }
14
-
15
- function getInstalledVersion() {
16
- try {
17
- const p = require.resolve(`${pkgName}/package.json`, { paths: [process.cwd(), __dirname] });
18
- return JSON.parse(fs.readFileSync(p, "utf8")).version;
19
- } catch {
20
- return null;
21
- }
22
- }
23
-
24
- async function checkAndUpdateVersion(callback) {
25
- try {
26
- logger("Checking version...", "info");
27
- const latest = (await execPromise(`npm view ${pkgName} version`)).stdout.trim();
28
- const installed = getInstalledVersion();
29
- if (!installed || installed !== latest) {
30
- logger(`New version available (${latest}). Current version (${installed || "not installed"}). Updating...`, "info");
31
- try {
32
- const { stderr } = await execPromise(`npm i ${pkgName}@latest`);
33
- if (stderr) logger(stderr, "error");
34
- logger(`Updated fca to the latest version: ${latest}, Restart to apply`, "info");
35
- callback(null);
36
- } catch (e) {
37
- logger(`Error running npm install: ${e.error || e}. Trying to install from GitHub...`, "error");
38
- try {
39
- const { stderr } = await execPromise("npm i https://github.com/Donix-VN/fca-unofficial");
40
- if (stderr) logger(stderr, "error");
41
- logger(`Installed from GitHub successfully: ${latest}`, "info");
42
- callback(null);
43
- } catch (gitErr) {
44
- logger(`Error installing from GitHub: ${gitErr.error || gitErr}`, "error");
45
- callback(gitErr.error || gitErr);
46
- }
47
- }
48
- } else {
49
- logger(`You're already on the latest version - ${latest}`, "info");
50
- callback(null);
51
- }
52
- } catch (err) {
53
- logger(`Error checking version: ${err}`, "error");
54
- callback(err);
55
- }
56
- }
57
-
58
- module.exports.checkAndUpdateVersion = checkAndUpdateVersion;
package/func/logger.js DELETED
@@ -1,48 +0,0 @@
1
- const chalk = require("chalk");
2
- const gradient = require("gradient-string");
3
-
4
- const themes = [
5
- "blue", "dream2", "dream", "fiery", "rainbow", "pastel", "cristal", "red", "aqua", "pink", "retro", "sunlight", "teen", "summer", "flower", "ghost", "hacker"
6
- ];
7
-
8
- function buildGradient(name) {
9
- const t = String(name || "").toLowerCase();
10
- if (t === "blue") return gradient([{ color: "#1affa3", pos: 0.2 }, { color: "cyan", pos: 0.4 }, { color: "pink", pos: 0.6 }, { color: "cyan", pos: 0.8 }, { color: "#1affa3", pos: 1 }]);
11
- if (t === "dream2") return gradient("blue", "pink");
12
- if (t === "dream") return gradient([{ color: "blue", pos: 0.2 }, { color: "pink", pos: 0.3 }, { color: "gold", pos: 0.6 }, { color: "pink", pos: 0.8 }, { color: "blue", pos: 1 }]);
13
- if (t === "fiery") return gradient("#fc2803", "#fc6f03", "#fcba03");
14
- if (t === "rainbow") return gradient.rainbow;
15
- if (t === "pastel") return gradient.pastel;
16
- if (t === "cristal") return gradient.cristal;
17
- if (t === "red") return gradient("red", "orange");
18
- if (t === "aqua") return gradient("#0030ff", "#4e6cf2");
19
- if (t === "pink") return gradient("#d94fff", "purple");
20
- if (t === "retro") return gradient.retro;
21
- if (t === "sunlight") return gradient("orange", "#ffff00", "#ffe600");
22
- if (t === "teen") return gradient.teen;
23
- if (t === "summer") return gradient.summer;
24
- if (t === "flower") return gradient("blue", "purple", "yellow", "#81ff6e");
25
- if (t === "ghost") return gradient.mind;
26
- if (t === "hacker") return gradient("#47a127", "#0eed19", "#27f231");
27
- return gradient("#243aff", "#4687f0", "#5800d4");
28
- }
29
-
30
- const themeName = themes[Math.floor(Math.random() * themes.length)];
31
- const co = buildGradient(themeName);
32
-
33
- module.exports = (text, type) => {
34
- const s = String(type || "info").toLowerCase();
35
- if (s === "warn") {
36
- process.stderr.write(co(`\r[ FCA-WARN ] > ${text}`) + "\n");
37
- return;
38
- }
39
- if (s === "error") {
40
- process.stderr.write(chalk.bold.hex("#ff0000")(`\r[ FCA-ERROR ]`) + ` > ${text}\n`);
41
- return;
42
- }
43
- if (s === "info") {
44
- process.stderr.write(chalk.bold(co(`\r[ FCA-UNO ] > ${text}`)) + "\n");
45
- return;
46
- }
47
- process.stderr.write(chalk.bold(co(`\r[ ${s.toUpperCase()} ] > ${text}`)) + "\n");
48
- };
package/func/login.js DELETED
File without changes