fscr 5.4.1 → 6.1.2
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 +1 -1
- package/dist/index.js +193 -49
- package/dist/lib/auth/auth-conf.js +63 -0
- package/dist/lib/codemod/arrow.js +13 -0
- package/dist/lib/codemod/arrow2.js +67 -0
- package/dist/lib/codemod/funcs.js +25 -0
- package/dist/lib/codemod/removeConsole.js +12 -0
- package/dist/lib/codemod/test.js +8 -0
- package/dist/lib/components/App.js +64 -0
- package/dist/lib/components/Selector.js +133 -0
- package/dist/lib/components/TabChanger.js +113 -0
- package/dist/lib/components/Table.js +177 -0
- package/dist/lib/components/Tabs.js +221 -0
- package/dist/lib/encryption/decryptConfig.js +81 -0
- package/dist/lib/encryption/encryption.js +135 -0
- package/dist/lib/generateFScripts.js +25 -0
- package/dist/lib/generateToc.js +36 -0
- package/dist/lib/generators/generateFScripts.js +25 -0
- package/dist/lib/generators/generateToc.js +38 -0
- package/dist/lib/generators/index.js +2 -0
- package/dist/lib/git/files.js +26 -0
- package/dist/lib/git/pub.js +42 -0
- package/dist/lib/git/taskRunner.js +80 -0
- package/dist/lib/git/validateNotDev.js +71 -0
- package/dist/lib/helpers.js +191 -0
- package/dist/lib/optionList.js +61 -0
- package/dist/lib/parseScriptsMd.js +93 -0
- package/dist/lib/parseScriptsPackage.js +9 -0
- package/dist/lib/parsers/parseScriptsMd.js +96 -0
- package/dist/lib/parsers/parseScriptsPackage.js +9 -0
- package/dist/lib/release/bump.js +52 -0
- package/dist/lib/release/commitWithMessage.js +65 -0
- package/dist/lib/release/index.js +4 -0
- package/dist/lib/release/publish.js +23 -0
- package/dist/lib/release/publish.sh +1 -0
- package/dist/lib/release/pushToGit.js +43 -0
- package/dist/lib/release/releasenotes.js +158 -0
- package/dist/lib/release/seeChangedFiles.js +89 -0
- package/dist/lib/release/sort.js +136 -0
- package/dist/lib/release/tree.js +163 -0
- package/dist/lib/release/validateNotDev.js +63 -0
- package/dist/lib/run/lib.js +454 -0
- package/dist/lib/run/main-p.js +59 -0
- package/dist/lib/run/main-s.js +56 -0
- package/dist/lib/run/parse-cli-args.js +222 -0
- package/dist/lib/run/run-p.js +30 -0
- package/dist/lib/run/run-s.js +57 -0
- package/dist/lib/runCLICommand.js +30 -0
- package/dist/lib/runParallel.js +20 -0
- package/dist/lib/runSequence.js +38 -0
- package/dist/lib/running/index.js +3 -0
- package/dist/lib/running/runCLICommand.js +38 -0
- package/dist/lib/running/runParallel.js +33 -0
- package/dist/lib/running/runSequence.js +43 -0
- package/dist/lib/startScripts.js +134 -0
- package/dist/lib/taskList.js +93 -0
- package/dist/lib/taskListAutoComplete.js +10 -0
- package/dist/lib/upgradePackages.js +65 -0
- package/dist/lib/utils/clear.js +18 -0
- package/dist/lib/utils/console.js +33 -0
- package/dist/lib/utils/encryption.js +18 -0
- package/dist/lib/utils/helpers.js +228 -0
- package/dist/lib/utils/index.js +2 -0
- package/dist/lib/utils/prompt.js +34 -0
- package/package.json +8 -7
- /package/dist/{index.html → lib/auth/index.html} +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
const separator = " ~ ";
|
|
3
|
+
import termSize from "term-size";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
const convertBold = e => {
|
|
6
|
+
let reg = /(\*\*|^\*\*)(?=\S)([\s\S]*?\S)\*\*(?![\*\*\S])/g;
|
|
7
|
+
let boldMatches = e.match(reg);
|
|
8
|
+
if (boldMatches !== null) {
|
|
9
|
+
boldMatches.forEach(m => {
|
|
10
|
+
e = e.replace(m, chalk.bold.redBright(m.replace(/\*\*/g, ""))); //.underline.bgBlack.whiteBright
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
let regunderline = /(_|^_)(?=\S)([\s\S]*?\S)_(?![_\S])/g;
|
|
14
|
+
let underlineMatches = e.match(regunderline);
|
|
15
|
+
if (underlineMatches !== null) {
|
|
16
|
+
underlineMatches.forEach(m => {
|
|
17
|
+
e = e.replace(m, chalk.underline.greenBright(m.replace(/\_\_/g, ""))); //.underline.bgBlack.whiteBright
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return e;
|
|
21
|
+
};
|
|
22
|
+
const convertBoldArray = arr => {
|
|
23
|
+
return arr.map(e => {
|
|
24
|
+
return convertBold(e);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const taskList = async (FcScripts, recentTasks) => {
|
|
28
|
+
return new Promise(resolve => {
|
|
29
|
+
let choiceCategories = [...recentTasks.map(cat => {
|
|
30
|
+
return {
|
|
31
|
+
name: `${chalk.bold.underline.green(cat)}`,
|
|
32
|
+
value: {
|
|
33
|
+
type: "task",
|
|
34
|
+
name: cat
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}), {
|
|
38
|
+
name: "-------------",
|
|
39
|
+
value: null
|
|
40
|
+
}, ...FcScripts.categories.map(cat => {
|
|
41
|
+
return {
|
|
42
|
+
name: `${chalk.bold.underline.green(cat.name)} ${separator} ${convertBold(cat.description)}`,
|
|
43
|
+
value: {
|
|
44
|
+
type: "category",
|
|
45
|
+
name: cat.name
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
})];
|
|
49
|
+
const {
|
|
50
|
+
rows
|
|
51
|
+
} = termSize();
|
|
52
|
+
//=> {columns: 143, rows: 24}
|
|
53
|
+
inquirer.prompt([{
|
|
54
|
+
type: "list",
|
|
55
|
+
name: "category",
|
|
56
|
+
message: "What category do you want to run?",
|
|
57
|
+
pageSize: rows - 1,
|
|
58
|
+
choices: choiceCategories
|
|
59
|
+
}]).then(({
|
|
60
|
+
category
|
|
61
|
+
}) => {
|
|
62
|
+
let sepInd = choiceCategories.indexOf("-------------");
|
|
63
|
+
let chosenInd = choiceCategories.indexOf(category);
|
|
64
|
+
if (category === null) {
|
|
65
|
+
console.log("Can't select divider");
|
|
66
|
+
} else if (category.type === "task") {
|
|
67
|
+
let taskToRun = category.name.split(separator)[0].trim();
|
|
68
|
+
resolve(taskToRun);
|
|
69
|
+
} else {
|
|
70
|
+
let categoryName = category.name.split(separator)[0];
|
|
71
|
+
let catObj = FcScripts.categories.findIndex(e => e.name === category.name);
|
|
72
|
+
catObj = FcScripts.categories[catObj];
|
|
73
|
+
let taskNames = Object.keys(catObj.tasks).map(taskName => {
|
|
74
|
+
let task = catObj.tasks[taskName];
|
|
75
|
+
return `${taskName} ${task.description ? separator + task.description.replace(/\n/g, " ").trim() : ""}`;
|
|
76
|
+
});
|
|
77
|
+
taskNames = convertBoldArray(taskNames);
|
|
78
|
+
inquirer.prompt([{
|
|
79
|
+
type: "list",
|
|
80
|
+
name: "taskToRun",
|
|
81
|
+
message: "Which task do you want to run",
|
|
82
|
+
choices: taskNames
|
|
83
|
+
}]).then(({
|
|
84
|
+
taskToRun
|
|
85
|
+
}) => {
|
|
86
|
+
taskToRun = taskToRun.split(separator)[0].trim();
|
|
87
|
+
resolve(taskToRun);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
export default taskList;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const scriptsDir = process.cwd();
|
|
2
|
+
import path from "path";
|
|
3
|
+
const rootDir = path.join(scriptsDir, "../");
|
|
4
|
+
const separator = " ~ ";
|
|
5
|
+
import Conf from "conf";
|
|
6
|
+
const config = new Conf();
|
|
7
|
+
export default taskListAutoComplete;
|
|
8
|
+
// (async () => {
|
|
9
|
+
// await startScripts();
|
|
10
|
+
// })();
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import childProcess from "child_process";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
const logError = message => {
|
|
9
|
+
console.log(chalk.red("[Error]: " + message));
|
|
10
|
+
};
|
|
11
|
+
const logInfo = message => {
|
|
12
|
+
console.log(chalk.blue("[Start]: " + message));
|
|
13
|
+
};
|
|
14
|
+
const logSuccess = message => {
|
|
15
|
+
console.log(chalk.green("[Done]: " + message));
|
|
16
|
+
};
|
|
17
|
+
let global = "";
|
|
18
|
+
let packagePath = path.resolve(process.cwd(), "package.json");
|
|
19
|
+
if (!fs.existsSync(packagePath)) {
|
|
20
|
+
logError("Cannot find package.json file in the current directory");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf-8"));
|
|
24
|
+
let ignorePkgs = [];
|
|
25
|
+
const upgradePackages = async () => {
|
|
26
|
+
if (packageJson["fscripts"]) {
|
|
27
|
+
if (packageJson["fscripts"]["ignore-upgrade"]) {
|
|
28
|
+
ignorePkgs = packageJson["fscripts"]["ignore-upgrade"];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
let upgraded = {
|
|
32
|
+
before: {},
|
|
33
|
+
after: {}
|
|
34
|
+
};
|
|
35
|
+
for (let element of ["dependencies", "devDependencies", "peerDependencies"]) {
|
|
36
|
+
if (packageJson[element]) {
|
|
37
|
+
const packages = Object.keys(packageJson[element]);
|
|
38
|
+
let packagesList = packages.filter(pkk => !ignorePkgs.includes(pkk)).map(pkk => {
|
|
39
|
+
upgraded["before"][pkk] = packageJson[element][pkk];
|
|
40
|
+
return pkk + "@latest";
|
|
41
|
+
}).join(" ");
|
|
42
|
+
let command = `yarn add ${packagesList}`;
|
|
43
|
+
try {
|
|
44
|
+
// logInfo(command);
|
|
45
|
+
childProcess.execSync(command, {
|
|
46
|
+
stdio: "inherit",
|
|
47
|
+
env: Object.assign({}, process.env, {
|
|
48
|
+
FORCE_COLOR: true,
|
|
49
|
+
PATH: `${path.resolve("node_modules")}:${process.env.PATH}`
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
const packageJsonAfter = JSON.parse(fs.readFileSync(packagePath));
|
|
53
|
+
const packagesAfter = Object.keys(packageJsonAfter[element]);
|
|
54
|
+
let packagesListAfter = packagesAfter.filter(pkk => !ignorePkgs.includes(pkk)).map(pkk => {
|
|
55
|
+
upgraded["after"][pkk] = packageJsonAfter[element][pkk];
|
|
56
|
+
return upgraded["before"][pkk] !== upgraded["after"][pkk] ? `Updated: ${pkk} from: ${upgraded["before"][pkk]} | to: ${upgraded["after"][pkk]}\n` : ``;
|
|
57
|
+
}).join("");
|
|
58
|
+
logSuccess(packagesListAfter);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
logError(`${command} - ${e}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export default upgradePackages;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clears console
|
|
3
|
+
* @param opts pass true to fully clear
|
|
4
|
+
*/
|
|
5
|
+
export default function clear(opts) {
|
|
6
|
+
if (typeof opts === "boolean") {
|
|
7
|
+
opts = {
|
|
8
|
+
fullClear: opts
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
opts = opts || {};
|
|
12
|
+
opts.fullClear = opts.hasOwnProperty("fullClear") ? opts.fullClear : true;
|
|
13
|
+
if (opts.fullClear === true) {
|
|
14
|
+
process.stdout.write("\x1b[2J");
|
|
15
|
+
}
|
|
16
|
+
process.stdout.write("\x1b[0f");
|
|
17
|
+
}
|
|
18
|
+
;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { timestamp } from "./helpers.js";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
const d = timestamp();
|
|
4
|
+
const colors = {
|
|
5
|
+
Reset: "\x1b[0m",
|
|
6
|
+
Red: "\x1b[31m",
|
|
7
|
+
Green: "\x1b[32m",
|
|
8
|
+
Yellow: "\x1b[33m"
|
|
9
|
+
};
|
|
10
|
+
const infoLog = console.info;
|
|
11
|
+
const logLog = console.log;
|
|
12
|
+
const warnLog = console.warn;
|
|
13
|
+
const errorLog = console.error;
|
|
14
|
+
console.log = function (args) {
|
|
15
|
+
const copyArgs = Array.prototype.slice.call(arguments);
|
|
16
|
+
copyArgs.unshift(`${chalk.gray(d)} ${chalk.gray.bold("[LOG]")}️`);
|
|
17
|
+
infoLog.apply(null, copyArgs);
|
|
18
|
+
};
|
|
19
|
+
console.info = function (args) {
|
|
20
|
+
const copyArgs = Array.prototype.slice.call(arguments);
|
|
21
|
+
copyArgs.unshift(`${chalk.gray(d)} ${chalk.blue.bold("i [INFO]")}️`);
|
|
22
|
+
infoLog.apply(null, copyArgs);
|
|
23
|
+
};
|
|
24
|
+
console.warn = function (args) {
|
|
25
|
+
const copyArgs = Array.prototype.slice.call(arguments);
|
|
26
|
+
copyArgs.unshift(`${chalk.gray(d)} ${chalk.yellow.bold("⚠ [WARN]")}️`);
|
|
27
|
+
warnLog.apply(null, copyArgs);
|
|
28
|
+
};
|
|
29
|
+
console.error = function (args) {
|
|
30
|
+
const copyArgs = Array.prototype.slice.call(arguments);
|
|
31
|
+
copyArgs.unshift(`${chalk.gray(d)} ${chalk.red.bold("× [ERROR]")}️`);
|
|
32
|
+
warnLog.apply(null, copyArgs);
|
|
33
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
const algorithm = "aes-192-cbc";
|
|
3
|
+
const iv = Buffer.alloc(16, 0); // Initialization vector.
|
|
4
|
+
const encrypt = (toEncrypt, password) => {
|
|
5
|
+
const key = crypto.scryptSync(password, "salt", 24);
|
|
6
|
+
const cipher = crypto.createCipheriv(algorithm, key, iv);
|
|
7
|
+
let encrypted = cipher.update(toEncrypt, "utf8", "hex");
|
|
8
|
+
encrypted += cipher.final("hex");
|
|
9
|
+
return encrypted;
|
|
10
|
+
};
|
|
11
|
+
const decrypt = (toDecrypt, password) => {
|
|
12
|
+
const key = crypto.scryptSync(password, "salt", 24);
|
|
13
|
+
const decipher = crypto.createDecipheriv(algorithm, key, iv);
|
|
14
|
+
let decrypted = decipher.update(toDecrypt, "hex", "utf8");
|
|
15
|
+
decrypted += decipher.final("utf8");
|
|
16
|
+
return decrypted;
|
|
17
|
+
};
|
|
18
|
+
export { decrypt, encrypt };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import boxen from "boxen";
|
|
4
|
+
const ONE_SIXTH = 1 / 6;
|
|
5
|
+
const ONE_THIRD = 1 / 3;
|
|
6
|
+
const TWO_THIRDS = 2 / 3;
|
|
7
|
+
const utils = {};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Output json file
|
|
11
|
+
* @param f - file name with directory
|
|
12
|
+
* @return {boolean}
|
|
13
|
+
* @example
|
|
14
|
+
const file = "/tmp/this/path/does/not/exist/file.json";
|
|
15
|
+
removeFile(file);
|
|
16
|
+
*/
|
|
17
|
+
utils.emptyDir = async f => {
|
|
18
|
+
try {
|
|
19
|
+
await fs.emptyDir(f);
|
|
20
|
+
// console.log(`${chalk.green.underline("Directory")} ${chalk.bold(f)} emptied!`);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error(err);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const desiredMode = 0o2775;
|
|
26
|
+
const defaultOptions = {
|
|
27
|
+
mode: desiredMode
|
|
28
|
+
};
|
|
29
|
+
utils.ensureDir = async (directory, options = defaultOptions) => {
|
|
30
|
+
try {
|
|
31
|
+
await fs.ensureDir(directory, options);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error(err);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
utils.ensureFile = async f => {
|
|
37
|
+
try {
|
|
38
|
+
await fs.ensureFile(f);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error(err);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Ensure path exists with dirs
|
|
46
|
+
* @param f the file path
|
|
47
|
+
* @return {boolean}
|
|
48
|
+
* @example
|
|
49
|
+
const file = ".fsr/config.json";
|
|
50
|
+
pathExists(file);
|
|
51
|
+
*/
|
|
52
|
+
utils.pathExists = async f => {
|
|
53
|
+
const exists = await fs.pathExists(f);
|
|
54
|
+
return exists;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Read json file
|
|
59
|
+
* @param f - file name with directory
|
|
60
|
+
* @return {Promise<void>}
|
|
61
|
+
* @example
|
|
62
|
+
const file = "/tmp/this/path/does/not/exist/file.json";
|
|
63
|
+
outputJson(file);
|
|
64
|
+
*/
|
|
65
|
+
utils.readJson = async f => {
|
|
66
|
+
try {
|
|
67
|
+
const packageObj = await fs.readJson(f);
|
|
68
|
+
// console.log(`${chalk.green.underline("File")} ${chalk.bold(f)} read!`);
|
|
69
|
+
return packageObj;
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.error(err);
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
utils.readFile = async f => {
|
|
76
|
+
try {
|
|
77
|
+
let fl = await fs.readFileSync(f, "utf8");
|
|
78
|
+
return fl;
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error(err);
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
utils.removeFile = async f => {
|
|
85
|
+
try {
|
|
86
|
+
// console.log(`${chalk.green.underline("File")} ${chalk.bold(f)} removed!`);
|
|
87
|
+
return await fs.remove(f);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.error(`File ${f} NOT REMOVED! ${err}`);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Write file
|
|
96
|
+
* @param f - file name with directory
|
|
97
|
+
* @param contents - text inside the file
|
|
98
|
+
* @return {Promise<void>}
|
|
99
|
+
* @example
|
|
100
|
+
const file = "/tmp/this/path/does/not/exist/file.json";
|
|
101
|
+
writeFile(file);
|
|
102
|
+
*/
|
|
103
|
+
utils.writeFile = async (f, contents = "") => {
|
|
104
|
+
try {
|
|
105
|
+
return fs.writeFileSync(f, contents, "utf-8");
|
|
106
|
+
// console.log(`${chalk.green.underline("File")} ${chalk.bold(f)} written!`);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
console.error(err);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
utils.writeJson = async (f, json = {}) => {
|
|
112
|
+
try {
|
|
113
|
+
await fs.writeJson(f, json);
|
|
114
|
+
// console.log(`${chalk.green.underline("File")} ${chalk.bold(f)} written!`);
|
|
115
|
+
} catch (err) {
|
|
116
|
+
console.error(err);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
utils.chainAsync = fns => {
|
|
120
|
+
let curr = 0;
|
|
121
|
+
const last = fns[fns.length - 1];
|
|
122
|
+
const next = () => {
|
|
123
|
+
const fn = fns[curr++];
|
|
124
|
+
fn === last ? fn() : fn(next);
|
|
125
|
+
};
|
|
126
|
+
next();
|
|
127
|
+
};
|
|
128
|
+
utils.appendToFile = async (f, contents = "") => {
|
|
129
|
+
try {
|
|
130
|
+
await fs.appendFileSync(f, contents);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
console.error(err);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
utils.boxInform = async (msg, secondary = "", padding = 0, margin = {
|
|
136
|
+
left: 2,
|
|
137
|
+
top: 0,
|
|
138
|
+
bottom: 0,
|
|
139
|
+
right: 0
|
|
140
|
+
}) => {
|
|
141
|
+
console.log(boxen(chalk.hex("#717877")(msg) + "\n" + chalk.bold.underline.hex("#438b34")(secondary) + chalk.hex("#717877")(" "), {
|
|
142
|
+
padding,
|
|
143
|
+
margin,
|
|
144
|
+
borderStyle: {
|
|
145
|
+
topLeft: chalk.hex("#5a596d")("╔"),
|
|
146
|
+
topRight: chalk.hex("#5a596d")("╗"),
|
|
147
|
+
bottomLeft: chalk.hex("#5a596d")("╚"),
|
|
148
|
+
bottomRight: chalk.hex("#5a596d")("╝"),
|
|
149
|
+
horizontal: chalk.hex("#5a596d")("═"),
|
|
150
|
+
vertical: chalk.hex("#5a596d")("║")
|
|
151
|
+
},
|
|
152
|
+
//"round",
|
|
153
|
+
align: "center" //,
|
|
154
|
+
}));
|
|
155
|
+
};
|
|
156
|
+
const hue2rgb = (p, q, t) => {
|
|
157
|
+
if (t < 0) {
|
|
158
|
+
t += 1;
|
|
159
|
+
}
|
|
160
|
+
if (t > 1) {
|
|
161
|
+
t -= 1;
|
|
162
|
+
}
|
|
163
|
+
if (t < ONE_SIXTH) {
|
|
164
|
+
return p + (q - p) * 6 * t;
|
|
165
|
+
}
|
|
166
|
+
if (t < 0.5) {
|
|
167
|
+
return q;
|
|
168
|
+
}
|
|
169
|
+
if (t < TWO_THIRDS) {
|
|
170
|
+
return p + (q - p) * (TWO_THIRDS - t) * 6;
|
|
171
|
+
}
|
|
172
|
+
return p;
|
|
173
|
+
};
|
|
174
|
+
const hsl2rgb = (h, s, l) => {
|
|
175
|
+
if (s === 0) {
|
|
176
|
+
return new Array(3).fill(l);
|
|
177
|
+
}
|
|
178
|
+
const q = l < 0.5 ? l * s + l : l + s - l * s;
|
|
179
|
+
const p = 2 * l - q;
|
|
180
|
+
return [hue2rgb(p, q, h + ONE_THIRD), hue2rgb(p, q, h), hue2rgb(p, q, h - ONE_THIRD)];
|
|
181
|
+
};
|
|
182
|
+
utils.rainbowGradient = (len, saturation = 1, lightness = 0.5) => {
|
|
183
|
+
const gradient = [];
|
|
184
|
+
for (let x = 0; x < len; x++) {
|
|
185
|
+
gradient.push(hsl2rgb(x / len, saturation, lightness).map(c => Math.round(c * 255)));
|
|
186
|
+
}
|
|
187
|
+
return gradient;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Return a timestamp with the format "m-d-yy_hh:MM:ss"
|
|
192
|
+
* @type {Date}
|
|
193
|
+
*/
|
|
194
|
+
utils.timestamp = () => {
|
|
195
|
+
// Create a date object with the current time
|
|
196
|
+
let now = new Date();
|
|
197
|
+
|
|
198
|
+
// Create an array with the current hour, minute and second
|
|
199
|
+
let time = [now.getHours(), now.getMinutes(), now.getSeconds()];
|
|
200
|
+
time = time.map(e => {
|
|
201
|
+
if (e < 10) {
|
|
202
|
+
return (e + "").padStart(2, "0");
|
|
203
|
+
} else {
|
|
204
|
+
return e;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
// Return the formatted string
|
|
208
|
+
return time.join(":");
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// utils.emptyDir = async () => {};
|
|
212
|
+
export default utils;
|
|
213
|
+
export const {
|
|
214
|
+
emptyDir,
|
|
215
|
+
ensureDir,
|
|
216
|
+
ensureFile,
|
|
217
|
+
pathExists,
|
|
218
|
+
readJson,
|
|
219
|
+
readFile,
|
|
220
|
+
removeFile,
|
|
221
|
+
writeFile,
|
|
222
|
+
writeJson,
|
|
223
|
+
chainAsync,
|
|
224
|
+
appendToFile,
|
|
225
|
+
boxInform,
|
|
226
|
+
rainbowGradient,
|
|
227
|
+
timestamp
|
|
228
|
+
} = utils;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import enquirerPkg from "enquirer";
|
|
2
|
+
const {
|
|
3
|
+
prompt
|
|
4
|
+
} = enquirerPkg;
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
const promptQuestion = async (extended = {}, message = `name it:`) => {
|
|
7
|
+
if (extended.type === "list") {
|
|
8
|
+
extended.type = "select";
|
|
9
|
+
}
|
|
10
|
+
if (extended.message) {
|
|
11
|
+
message = extended.message;
|
|
12
|
+
}
|
|
13
|
+
if (extended.choices && extended.choices[0].value) {
|
|
14
|
+
extended.choices = extended.choices.map(e => {
|
|
15
|
+
return {
|
|
16
|
+
message: e.name,
|
|
17
|
+
value: e.value
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (extended.pageSize) {
|
|
22
|
+
extended.limit = extended.pageSize;
|
|
23
|
+
}
|
|
24
|
+
const {
|
|
25
|
+
answer
|
|
26
|
+
} = await prompt({
|
|
27
|
+
type: "input",
|
|
28
|
+
message: `${chalk.green.bold.underline(message)}`,
|
|
29
|
+
name: `answer`,
|
|
30
|
+
...extended
|
|
31
|
+
});
|
|
32
|
+
return answer;
|
|
33
|
+
};
|
|
34
|
+
export default promptQuestion;
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fscr",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.2",
|
|
4
4
|
"description": "Runs the fscripts.md file",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "./dist/index.js",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"prebuild": "rimraf dist/*",
|
|
@@ -10,7 +11,8 @@
|
|
|
10
11
|
"build:lib": "babel lib --ignore 'node_modules' --out-dir dist/lib --copy-files",
|
|
11
12
|
"fsr": "node dist/index.js",
|
|
12
13
|
"release": "run-s release:bump release:clean release:build release:publish",
|
|
13
|
-
"release:build": "parcel build index.js --target node --no-cache --no-source-maps",
|
|
14
|
+
"old:release:build": "parcel build index.js --target node --no-cache --no-source-maps",
|
|
15
|
+
"release:build": "run-p build:index build:lib",
|
|
14
16
|
"release:bump": "yarn fsr bump",
|
|
15
17
|
"release:clean": "rimraf dist",
|
|
16
18
|
"release:combined": "np --any-branch",
|
|
@@ -43,7 +45,8 @@
|
|
|
43
45
|
"license": "MIT",
|
|
44
46
|
"author": "Angel Grablev <agrublev@gmail.com>",
|
|
45
47
|
"files": [
|
|
46
|
-
"dist"
|
|
48
|
+
"dist",
|
|
49
|
+
"bin"
|
|
47
50
|
],
|
|
48
51
|
"bin": {
|
|
49
52
|
"fscr": "./bin",
|
|
@@ -118,7 +121,6 @@
|
|
|
118
121
|
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
|
119
122
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
120
123
|
"babel-plugin-transform-remove-console": "^6.9.4",
|
|
121
|
-
"eslint-plugin-prettier": "^3.1.2",
|
|
122
124
|
"fancy-log": "^1.3.3",
|
|
123
125
|
"fkill-cli": "^6.0.1",
|
|
124
126
|
"google-auth-library": "^6.0.0",
|
|
@@ -140,14 +142,12 @@
|
|
|
140
142
|
"parcel-bundler": "^1.12.5",
|
|
141
143
|
"parcel-plugin-copy": "^1.0.2",
|
|
142
144
|
"prepend-file": "^1.3.1",
|
|
143
|
-
"prettier": "^2.0.1",
|
|
144
145
|
"pretty-console-colors": "^1.1.1",
|
|
145
146
|
"pull-request": "^3.0.0",
|
|
146
147
|
"react": "^16.13.1",
|
|
147
148
|
"remarkable": "^2.0.0",
|
|
148
149
|
"rexrex": "^1.3.0",
|
|
149
150
|
"rimraf": "^3.0.2",
|
|
150
|
-
"semantic-release": "^17.0.4",
|
|
151
151
|
"term-size": "^2.2.0",
|
|
152
152
|
"terminal-tree": "^0.0.3",
|
|
153
153
|
"underscore.string": "^3.3.5",
|
|
@@ -155,5 +155,6 @@
|
|
|
155
155
|
},
|
|
156
156
|
"peerDependencies": {
|
|
157
157
|
"chalk": "^2.4.2"
|
|
158
|
-
}
|
|
158
|
+
},
|
|
159
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
159
160
|
}
|
|
File without changes
|