fscr 6.2.3 → 7.3.0

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.
Files changed (98) hide show
  1. package/README.md +48 -30
  2. package/dist/index.js +502 -185
  3. package/dist/lib/auth/auth-conf.js +49 -45
  4. package/dist/lib/cache/README.md +341 -0
  5. package/dist/lib/cache/cli.js +152 -0
  6. package/dist/lib/cache/file-watcher.js +193 -0
  7. package/dist/lib/cache/index.js +422 -0
  8. package/dist/lib/cache/monitor.js +224 -0
  9. package/dist/lib/commands/doctor.js +225 -0
  10. package/dist/lib/completions/completion.js +342 -0
  11. package/dist/lib/completions/generator.js +152 -0
  12. package/dist/lib/completions/scripts/bash.sh +108 -0
  13. package/dist/lib/completions/scripts/fish.sh +105 -0
  14. package/dist/lib/completions/scripts/powershell.ps1 +168 -0
  15. package/dist/lib/completions/scripts/zsh.sh +124 -0
  16. package/dist/lib/diagnostics/cache.js +121 -0
  17. package/dist/lib/diagnostics/fileSystem.js +236 -0
  18. package/dist/lib/diagnostics/gitCheck.js +41 -0
  19. package/dist/lib/diagnostics/nodeVersion.js +68 -0
  20. package/dist/lib/diagnostics/packageManager.js +64 -0
  21. package/dist/lib/diagnostics/performance.js +141 -0
  22. package/dist/lib/encryption/decryptConfig.js +3 -2
  23. package/dist/lib/encryption/encryption.js +153 -113
  24. package/dist/lib/generators/generateFScripts.js +16 -13
  25. package/dist/lib/generators/generateToc.js +23 -14
  26. package/dist/lib/generators/index.js +1 -1
  27. package/dist/lib/git/pub.js +27 -31
  28. package/dist/lib/git/taskRunner.js +79 -69
  29. package/dist/lib/git/validateNotDev.js +65 -54
  30. package/dist/lib/optionList.js +69 -57
  31. package/dist/lib/parsers/parseScriptsMd.cached.js +208 -0
  32. package/dist/lib/parsers/parseScriptsMd.js +88 -79
  33. package/dist/lib/parsers/parseScriptsPackage.js +4 -3
  34. package/dist/lib/performance/cache.js +199 -0
  35. package/dist/lib/performance/lazy-loader.js +189 -0
  36. package/dist/lib/performance/monitor.js +303 -0
  37. package/dist/lib/plugins/deployment/index.js +113 -0
  38. package/dist/lib/plugins/hooks.js +17 -0
  39. package/dist/lib/plugins/loader.js +91 -0
  40. package/dist/lib/plugins/task-notifier/index.js +72 -0
  41. package/dist/lib/release/bump.js +51 -43
  42. package/dist/lib/release/commitWithMessage.js +80 -52
  43. package/dist/lib/release/publish.js +19 -14
  44. package/dist/lib/release/pushToGit.js +40 -31
  45. package/dist/lib/release/releasenotes.js +116 -97
  46. package/dist/lib/release/seeChangedFiles.js +68 -60
  47. package/dist/lib/release/sort.js +200 -116
  48. package/dist/lib/release/tree.js +161 -147
  49. package/dist/lib/release/validateNotDev.js +52 -44
  50. package/dist/lib/running/index.js +1 -1
  51. package/dist/lib/running/runCLICommand.js +41 -31
  52. package/dist/lib/running/runParallel.js +61 -59
  53. package/dist/lib/running/runSequence.js +55 -53
  54. package/dist/lib/startScripts.js +129 -114
  55. package/dist/lib/taskList.js +99 -84
  56. package/dist/lib/test-files/.fscripts.md +113 -0
  57. package/dist/lib/test-files/.fscripts.test.md +103 -0
  58. package/dist/lib/test-files/.fscriptsb.md +107 -0
  59. package/dist/lib/test-files/.mdtest.md +40 -0
  60. package/dist/lib/test-files/consoleSample.js +17 -0
  61. package/dist/lib/test-files/inputSample.js +20 -0
  62. package/dist/lib/test-files/testConsole.js +1 -0
  63. package/dist/lib/test-files/testInput.js +2 -0
  64. package/dist/lib/upgradePackages.js +56 -46
  65. package/dist/lib/utils/clear.js +16 -13
  66. package/dist/lib/utils/console.js +27 -21
  67. package/dist/lib/utils/encryption.js +55 -13
  68. package/dist/lib/utils/hash.js +128 -0
  69. package/dist/lib/utils/helpers.js +153 -142
  70. package/dist/lib/utils/index.js +1 -1
  71. package/dist/lib/utils/prompt.js +24 -29
  72. package/package.json +20 -32
  73. package/dist/lib/codemod/arrow.js +0 -13
  74. package/dist/lib/codemod/arrow2.js +0 -67
  75. package/dist/lib/codemod/funcs.js +0 -25
  76. package/dist/lib/codemod/removeConsole.js +0 -12
  77. package/dist/lib/codemod/test.js +0 -8
  78. package/dist/lib/components/App.js +0 -64
  79. package/dist/lib/components/Selector.js +0 -133
  80. package/dist/lib/components/TabChanger.js +0 -113
  81. package/dist/lib/components/Table.js +0 -177
  82. package/dist/lib/components/Tabs.js +0 -221
  83. package/dist/lib/generateFScripts.js +0 -25
  84. package/dist/lib/generateToc.js +0 -30
  85. package/dist/lib/helpers.js +0 -191
  86. package/dist/lib/parseScriptsMd.js +0 -85
  87. package/dist/lib/parseScriptsPackage.js +0 -9
  88. package/dist/lib/release/index.js +0 -4
  89. package/dist/lib/run/lib.js +0 -454
  90. package/dist/lib/run/main-p.js +0 -59
  91. package/dist/lib/run/main-s.js +0 -56
  92. package/dist/lib/run/parse-cli-args.js +0 -222
  93. package/dist/lib/run/run-p.js +0 -30
  94. package/dist/lib/run/run-s.js +0 -57
  95. package/dist/lib/runCLICommand.js +0 -30
  96. package/dist/lib/runParallel.js +0 -20
  97. package/dist/lib/runSequence.js +0 -38
  98. 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;
@@ -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;
@@ -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;
@@ -1,4 +0,0 @@
1
- import bump from "./bump.js";
2
- (async () => {
3
- await bump();
4
- })();