fscr 6.2.2 → 6.2.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/dist/index.js +43 -25
- package/dist/lib/git/pub.js +0 -14
- package/dist/lib/release/bump.js +9 -6
- package/dist/lib/running/runParallel.js +43 -25
- package/dist/lib/running/runSequence.js +41 -24
- package/dist/lib/taskList.js +69 -61
- package/dist/lib/test-files/consoleSample.js +13 -0
- package/dist/lib/test-files/inputSample.js +17 -0
- package/dist/lib/test-files/testConsole.js +1 -0
- package/dist/lib/test-files/testInput.js +2 -0
- package/package.json +12 -6
- package/dist/lib/codemod/arrow.js +0 -13
- package/dist/lib/codemod/arrow2.js +0 -67
- package/dist/lib/codemod/funcs.js +0 -25
- package/dist/lib/codemod/removeConsole.js +0 -12
- package/dist/lib/codemod/test.js +0 -8
- package/dist/lib/components/App.js +0 -64
- package/dist/lib/components/Selector.js +0 -133
- package/dist/lib/components/TabChanger.js +0 -113
- package/dist/lib/components/Table.js +0 -177
- package/dist/lib/components/Tabs.js +0 -221
- package/dist/lib/generateFScripts.js +0 -25
- package/dist/lib/generateToc.js +0 -30
- package/dist/lib/helpers.js +0 -191
- package/dist/lib/parseScriptsMd.js +0 -85
- package/dist/lib/parseScriptsPackage.js +0 -9
- package/dist/lib/release/index.js +0 -4
- package/dist/lib/run/lib.js +0 -454
- package/dist/lib/run/main-p.js +0 -59
- package/dist/lib/run/main-s.js +0 -56
- package/dist/lib/run/parse-cli-args.js +0 -222
- package/dist/lib/run/run-p.js +0 -30
- package/dist/lib/run/run-s.js +0 -57
- package/dist/lib/runCLICommand.js +0 -30
- package/dist/lib/runParallel.js +0 -20
- package/dist/lib/runSequence.js +0 -38
- package/dist/lib/taskListAutoComplete.js +0 -15
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import inquirer from "inquirer";
|
|
3
|
-
import { appendToFile, writeFile, boxInform, readJson, readFile } from "./utils/helpers.js";
|
|
4
|
-
import path from "path";
|
|
5
|
-
const projectDir = process.cwd();
|
|
6
|
-
const packagePath = path.join(projectDir, "package.json");
|
|
7
|
-
const gen = {
|
|
8
|
-
scripts: []
|
|
9
|
-
};
|
|
10
|
-
let mdfile = `# First category of scripts
|
|
11
|
-
|
|
12
|
-
Welcome to your new amazing fscripts.md file. It replaces the headaches of npm scripts! But so much more.
|
|
13
|
-
`;
|
|
14
|
-
gen.init = async () => {
|
|
15
|
-
try {
|
|
16
|
-
gen.packageJson = await readJson(packagePath);
|
|
17
|
-
Object.keys(gen.packageJson.scripts).forEach(scriptName => {
|
|
18
|
-
mdfile += `\n## ${scriptName}\n\n${gen.packageJson.scripts[scriptName]}\n\n\`\`\`bash\n${gen.packageJson.scripts[scriptName]}\n\`\`\`\n\n`;
|
|
19
|
-
});
|
|
20
|
-
await writeFile("./sample.fscripts.md", mdfile);
|
|
21
|
-
} catch (err) {
|
|
22
|
-
console.error(err);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
export default gen.init;
|
package/dist/lib/generateToc.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
import tocPkg from "markdown-toc";
|
|
5
|
-
const toc = tocPkg.default || tocPkg;
|
|
6
|
-
import { writeFile } from "./utils/helpers.js";
|
|
7
|
-
// const projectDir = process.cwd();
|
|
8
|
-
|
|
9
|
-
const generateToc = async () => {
|
|
10
|
-
const filepath = path.resolve(process.cwd(), "fscripts.md");
|
|
11
|
-
if (!fs.existsSync(filepath)) {
|
|
12
|
-
console.warn(`${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
13
|
-
${chalk.green("Please run 'fsr generate' to get started!")}`);
|
|
14
|
-
process.exit(0);
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
const data = fs.readFileSync(filepath, "utf-8");
|
|
18
|
-
if (data) {
|
|
19
|
-
console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
|
|
20
|
-
let newFile = ``;
|
|
21
|
-
let tocSplit = data.split("<!-- end toc -->");
|
|
22
|
-
if (tocSplit.length === 2) {
|
|
23
|
-
newFile = toc(tocSplit[1]).content + "\n<!-- end toc -->\n\n" + tocSplit[1].trim();
|
|
24
|
-
} else {
|
|
25
|
-
newFile = toc(data).content + "\n<!-- end toc -->\n\n" + data.trim();
|
|
26
|
-
}
|
|
27
|
-
await writeFile("./fscripts.md", newFile);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
export default generateToc;
|
package/dist/lib/helpers.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
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
|
-
// utils.emptyDir = async () => {};
|
|
191
|
-
export default utils;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
const flattenObject = (obj, prefix = "") => Object.keys(obj).reduce((acc, k) => {
|
|
5
|
-
const pre = prefix.length ? prefix + "." : "";
|
|
6
|
-
if (typeof obj[k] === "object") Object.assign(acc, flattenObject(obj[k], pre + k));else acc[pre + k] = obj[k];
|
|
7
|
-
return acc;
|
|
8
|
-
}, {});
|
|
9
|
-
import marked from "marked";
|
|
10
|
-
let parse = function (mdContent) {
|
|
11
|
-
let js = marked.lexer(mdContent);
|
|
12
|
-
js = js.filter(e => e.type !== "space");
|
|
13
|
-
|
|
14
|
-
// let firstHeading = js.findIndex(e => e.type === "heading" && e.depth === 1); //?
|
|
15
|
-
let listMe = js.slice();
|
|
16
|
-
let tempItem = {};
|
|
17
|
-
let currentCategory = "";
|
|
18
|
-
let currentTask = "";
|
|
19
|
-
let taskOrder = 0;
|
|
20
|
-
listMe.forEach((item, indx) => {
|
|
21
|
-
if (item.type === "heading" && item.depth === 1) {
|
|
22
|
-
taskOrder = 0;
|
|
23
|
-
currentCategory = item.text;
|
|
24
|
-
tempItem[currentCategory] = {
|
|
25
|
-
name: item.text,
|
|
26
|
-
tasks: {},
|
|
27
|
-
description: ""
|
|
28
|
-
};
|
|
29
|
-
let descriptor = js[indx + 1];
|
|
30
|
-
if (descriptor.type === "paragraph") {
|
|
31
|
-
tempItem[currentCategory].description = descriptor.text;
|
|
32
|
-
}
|
|
33
|
-
} else if (item.type === "heading" && item.depth === 2) {
|
|
34
|
-
currentTask = item.text;
|
|
35
|
-
tempItem[currentCategory].tasks[currentTask] = {
|
|
36
|
-
script: "",
|
|
37
|
-
name: currentTask,
|
|
38
|
-
description: "",
|
|
39
|
-
order: taskOrder
|
|
40
|
-
};
|
|
41
|
-
taskOrder++;
|
|
42
|
-
let descriptor = js[indx + 1];
|
|
43
|
-
let code = js[indx + 2];
|
|
44
|
-
if (descriptor.type === "paragraph" && code.type === "code") {
|
|
45
|
-
tempItem[currentCategory].tasks[currentTask].description = descriptor.text;
|
|
46
|
-
tempItem[currentCategory].tasks[currentTask].script = code.text;
|
|
47
|
-
} else if (descriptor.type === "code") {
|
|
48
|
-
tempItem[currentCategory].tasks[currentTask].script = descriptor.text;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
let allTasks = [];
|
|
53
|
-
let categories = Object.keys(tempItem).map(catName => {
|
|
54
|
-
let ts = tempItem[catName].tasks;
|
|
55
|
-
let tasksArr = Object.keys(ts).map(tn => ts[tn]);
|
|
56
|
-
allTasks = [...allTasks, ...tasksArr];
|
|
57
|
-
return {
|
|
58
|
-
name: catName,
|
|
59
|
-
...tempItem[catName]
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
return {
|
|
63
|
-
categories,
|
|
64
|
-
allTasks
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
const parseScriptFile = async () => {
|
|
68
|
-
const data = await fs.readFileSync(path.resolve(process.cwd(), "fscripts.md"), "utf-8");
|
|
69
|
-
if (!data) {
|
|
70
|
-
// console.warn(
|
|
71
|
-
// `${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
72
|
-
// ${chalk.green("Please run 'fsr generate' to get started!")}`
|
|
73
|
-
// );
|
|
74
|
-
//
|
|
75
|
-
// process.exit(0);
|
|
76
|
-
// return null;
|
|
77
|
-
return false;
|
|
78
|
-
} else {
|
|
79
|
-
// console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
|
|
80
|
-
let newContent = data.split("<!-- end toc -->");
|
|
81
|
-
newContent = newContent[newContent.length === 2 ? 1 : 0];
|
|
82
|
-
return parse(newContent);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
export default parseScriptFile;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
const projectPath = path.join(process.cwd(), "./package.json");
|
|
4
|
-
import { readJson } from "./utils/helpers.js";
|
|
5
|
-
const parseScriptFile = async () => {
|
|
6
|
-
const packageFile = await readJson(projectPath);
|
|
7
|
-
return packageFile.scripts;
|
|
8
|
-
};
|
|
9
|
-
export default parseScriptFile;
|